I want to get updated documents. This is my original code and it succesfully updates but doesnt return the document.
collection.update({ \"code\": req.bo
Checkout the WriteResult object:
http://docs.mongodb.org/manual/reference/method/db.collection.update/#writeresults-update
WriteResult result = collection.update({ "code": req.body.code },{$set: req.body.updatedFields}, function(err, results) {
res.send({error: err, affected: results});
db.close();
});
result should have something like:
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
If you want the updated results, do another query with the primary key.