node.js - Problems with multiple update in MongoDb -
i have mongo structure this:
{ "_id" : objectid("51596b7e469b9c3816000001"), "company" : { "_id" : "ade2fd0ec9b8b5e9152e0155", "title" : "lo3426546457" }, } { "_id" : objectid("51596cef469b9c3816000008"), "company" : { "_id" : "ade2fd0ec9b8b5e9152e0155", "title" : "lo3426546457" }, } { "_id" : objectid("51596cc3469b9c3816000007"), "company" : { "_id" : "ade2fd0ec9b8b5e9152e0155", "title" : "lo3426546457" } }
and want change 'title' fields objects specific '_id'. this:
collections.userscollection.update({ 'company._id': 'ade2fd0ec9b8b5e9152e0155' }, { $set: { 'company': { _id: 'ade2fd0ec9b8b5e9152e0155', title: 'blablabla' } // tried: 'company.title': 'blablabla' } }, false, true);
and after execution code in node.js (i use node-mongodb-native), mongo updates only one document.
but if command @ mongo shell (mongo.exe), works fine , updates documents.
what's problem?
by default mongo updates single document. http://docs.mongodb.org/manual/reference/method/db.collection.update/
use multi option multiple document update.
Comments
Post a Comment