-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Docs
From driver documentation for find_and_modify operation at http://mongoc.org/libmongoc/current/mongoc_collection_find_and_modify.html?highlight=find_and_modify:
"Returns either the document before or after modification based on the _new parameter."
However, as far as I checked what is returned (in the reply parameter) is not the document, but a kind of "wraper" with the document:
{ "lastErrorObject": { "n": 1, "updatedExisting": true }, "value": <here is the document>, "ok": 1.0 }
Not this is not the behaviour if we use findAndModify() in the MongoShell. Example:
> db.x.insert({x:1}) WriteResult({ "nInserted" : 1 }) > db.x.findAndModify({query: {x:1}, update: {$inc: {x:1}}, new: true }) { "_id" : ObjectId("615acd3a3b41c7be44a3374e"), "x" : 2 }
I understand the driver documentation should explain this (thus, this issue is a kind of "documentation bug").