Quantcast
Channel: MarsHut
Viewing all articles
Browse latest Browse all 6551

mongo db multi record not working

$
0
0
3 records need to be updated when I use multi:true only one got it update
which is similar to NOT using multi:true. Is something wrong with the
update statement ? thanks for response.

test@-Mongo-> db.transactions.find();
{ "_id" : ObjectId("536629e371ac8ef534bb2500"), "source" : "A",
"destination" : "B", "value" : 100, "state" : "initial" }
{ "_id" : ObjectId("53662a6e71ac8ef534bb2501"), "source" : "A",
"destination" : "B", "value" : 100, "state" : "initial" }
{ "_id" : ObjectId("53664fb471ac8ef534bb2502"), "source" : "A",
"destination" : "B", "value" : 100, "state" : "initial" }

test@-Mongo-> db.transactions.update({_id: t._id}, {$set: {state: "pending
"}},{upsert:false,multi:true});

WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
test@-Mongo-> db.transactions.find();
{ "_id" : ObjectId("536629e371ac8ef534bb2500"), "source" : "A",
"destination" : "B", "value" : 100, "state" : "pending " }
{ "_id" : ObjectId("53662a6e71ac8ef534bb2501"), "source" : "A",
"destination" : "B", "value" : 100, "state" : "initial" }
{ "_id" : ObjectId("53664fb471ac8ef534bb2502"), "source" : "A",
"destination" : "B", "value" : 100, "state" : "initial" }

For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.

You received this message because you are subscribed to the Google Groups "mongodb-user" group.

To post to this group, send email to mongodb-user [ at ] googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ba319006-5fe0-4798-b882-95a9a8116fc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Viewing all articles
Browse latest Browse all 6551

Trending Articles