Reputation: 25120
I need to find and modify first matched element using mongodb. Is it possible? I failed to find how to do it from official doc: http://www.mongodb.org/display/DOCS/findAndModify+Command
There is not findAndModifyOne method.
Upvotes: 3
Views: 3958
Reputation: 26278
According to the docs "This command can be used to atomically modify a document (at most one) and return it." (emphasis mine)
Edit: If you use the sort
argument to findAndModify
, then it will operate on the first result found according to the sort criteria.
Upvotes: 5