Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4173

mongoc_collection_find_and_modify documentation is not fully correct

      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").

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            fermin.galanmarquez@telefonica.com Fermín Galán
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: