Created
January 31, 2011 22:35
-
-
Save slyphon/804981 to your computer and use it in GitHub Desktop.
findAndModify is confusing me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.messages.find() | |
{ "_id" : "msgid:test:e9f1aca0-2d86-11e0-9695-138376569236", "status" : "incomplete", "expires" : 1296598229, "timeout" : 1296512429 } | |
{ "_id" : "msgid:test:f93bf066-2d87-11e0-ab0b-d7db09943f10", "status" : "incomplete", "expires" : 1296598684, "timeout" : 1296512884 } | |
> db.messages.find( { _id : "msgid:test:f93bf066-2d87-11e0-ab0b-d7db09943f10" } ) | |
{ "_id" : "msgid:test:f93bf066-2d87-11e0-ab0b-d7db09943f10", "status" : "incomplete", "expires" : 1296598684, "timeout" : 1296512884 } | |
> cmd = { | |
... findAndModify : "messages", | |
... query : { _id : "msgid:test:f93bf066-2d87-11e0-ab0b-d7db09943f10" }, | |
... update : { $inc : { attempts : 1 } }, | |
... new : true, | |
... fields : { "_id" : 0, "attempts" : 1 } | |
... }; | |
{ | |
"findAndModify" : "messages", | |
"query" : { | |
"_id" : "msgid:test:f93bf066-2d87-11e0-ab0b-d7db09943f10" | |
}, | |
"update" : { | |
"$inc" : { | |
"attempts" : 1 | |
} | |
}, | |
"new" : true, | |
"fields" : { | |
"_id" : 0, | |
"attempts" : 1 | |
} | |
} | |
> | |
> db.runCommand(cmd); | |
{ "errmsg" : "No matching object found", "ok" : 0 } | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment