showing results for - "node js 3a e2 80 9creturnnewdocument 3a true e2 80 9d not working"
Filippo
13 May 2020
1// /node-mongodb-native//4.0 driver 
2//returnOriginal is Deprecated Use options.returnDocument instead.
3returnDocument	'before' | 'after'
4When set to 'after',returns the updated document rather than the original
5When set to 'before',returns the original document rather than the updated.
6The default is 'before'.
7
8const options = { returnDocument: 'after' };
9//same for findOneAndReplace
10myDataBase.findOneAndUpdate(query, update, options, (err, doc) => {
11   if (err) {
12          console.log("Something wrong when updating data!");
13        }
14        else if (!doc.lastErrorObject.updatedExisting && doc.value == null)
15          return res.json('no book exists')
16  
17 // The updated document is held within the value property of the response
18        console.log('doc.value');
19        console.log(doc.value);
20})
21
22//https://stackoverflow.com/a/67909382/918069/
23