You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/content/tutorials/crud.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,7 @@ methods, the operation takes a write lock for the duration of the operation in o
354
354
355
355
// Modify and return the modified document
356
356
col.findOneAndUpdate({a:1}, {$set: {b: 1}}, {
357
-
returnOriginal: false
357
+
returnDocument: 'after'
358
358
, sort: [[a,1]]
359
359
, upsert: true
360
360
}, function(err, r) {
@@ -382,7 +382,7 @@ methods, the operation takes a write lock for the duration of the operation in o
382
382
383
383
// Modify and return the modified document
384
384
r = await col.findOneAndUpdate({a:1}, {$set: {b: 1}}, {
385
-
returnOriginal: false
385
+
returnDocument: 'after'
386
386
, sort: [[a,1]]
387
387
, upsert: true
388
388
});
@@ -410,7 +410,7 @@ The ``findOneAndUpdate`` method also accepts a third argument which can be an op
410
410
|`upsert`| (Boolean, default:false) | Perform an upsert operation. |
411
411
|`sort`| (Object, default:null) | Sort for find operation. |
412
412
|`projection`| (Object, default:null) | Projection for returned result |
413
-
|`returnOriginal`| (Boolean, default:true) | Set to false if you want to return the modified object rather than the original. Ignored for remove. |
413
+
|`returnDocument`| (String, 'before' \|\| 'after', default:'before') | Set to 'after' if you want to return the modified document rather than the original. Ignored for remove. |
414
414
415
415
The ``findOneAndDelete`` function is designed to help remove a document.
* @property {object} value Document returned from the `findAndModify` command. If no documents were found, `value` will be `null` by default (`returnOriginal: true`), even if a document was upserted; if `returnOriginal` was false, the upserted document will be returned in that case.
1658
+
* @property {object} value Document returned from the `findAndModify` command. If no documents were found, `value` will be `null` by default even if a document was upserted unless `returnDocument` is specified as `'after'`, in which case the upserted document will be returned.
1659
1659
* @property {object} lastErrorObject The raw lastErrorObject returned from the command. See {@link https://docs.mongodb.com/manual/reference/command/findAndModify/index.html#lasterrorobject|findAndModify command documentation}.
1660
1660
* @property {Number} ok Is 1 if the command executed correctly.
* @param {object} [options.projection] Limits the fields to return for all matching documents.
1717
1717
* @param {object} [options.sort] Determines which document the operation modifies if the query selects multiple documents.
1718
1718
* @param {boolean} [options.upsert=false] Upsert the document if it does not exist.
1719
-
* @param {boolean} [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true.
1719
+
* @param {'before'|'after'} [options.returnDocument='before'] When set to `'after'`, returns the updated document rather than the original. The default is `'before'`.
1720
+
* @param {boolean} [options.returnOriginal=true] **Deprecated** Use `options.returnDocument` instead.
1720
1721
* @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
1721
1722
* @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
1722
1723
* @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
* @param {object} [options.projection] Limits the fields to return for all matching documents.
1758
1766
* @param {object} [options.sort] Determines which document the operation modifies if the query selects multiple documents.
1759
1767
* @param {boolean} [options.upsert=false] Upsert the document if it does not exist.
1760
-
* @param {boolean} [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true.
1768
+
* @param {'before'|'after'} [options.returnDocument='before'] When set to `'after'`, returns the updated document rather than the original. The default is `'before'`.
1769
+
* @param {boolean} [options.returnOriginal=true] **Deprecated** Use `options.returnDocument` instead.
1761
1770
* @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
1762
1771
* @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
1763
1772
* @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
0 commit comments