Why does my update $set code remove my entire document?

80 views Asked by At

Help! I don't what am doing wrong, when I try to update an existing field using the $set method the entire document gets removed.

Can you kindly point out what I am doing wrong in my code:

recipientsDetails.update({_id: "GCYmFqZbaaYD7DvMZ"}, {$set: {paymentStatus: "Approved"}});

Thanks for your help!

2

There are 2 answers

2
DoctorPangloss On BEST ANSWER

The code is correct. It's likely that your publish function for recipientsDetails contains recipientsDetails.find({paymentStatus: "Not Approved"}). Naturally, once you update the document, the document will no longer satisfy that filtering query and the document vanish from the client.

0
Thusila Bandara On

Your code is correct.Check you mongoDB using Robomongo tool.connect your local project with robomongo and update a document then check whether it is updated or not? If the record updated there is an issue with the publish or subscriptions