Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongodb findoneandupdate return new document

const update = await client.db('database').collection('col').findOneAndUpdate({
      'param': 'value'
    }, {
      $set: {
        'param': 'newvalue'
      }
    }, {
      returnDocument: 'after',
      projection: {
        param: 1
      }
    })
 
PREVIOUS NEXT
Tagged: #mongodb #findoneandupdate #return #document
ADD COMMENT
Topic
Name
2+4 =