Skip to content

Commit fe8b4d7

Browse files
committed
reword findOneAndUpsert inconsistent behavior mention
1 parent 5309c20 commit fe8b4d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ MongoClient.connect('mongodb://localhost:27017/test', function(err, db) {
578578
Upsert a single document on MongoDB.
579579

580580
**⚠️ Important**. Uses [`findOneAnReplace`](https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#findOneAndReplace) and [`findOneAndUpdate`](https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#findOneAndUpdate) with `upsert` option under the hood.
581-
`findOneAndReplace` will be used, if update parameter do not contain any [update operators](https://docs.mongodb.com/v3.6/reference/operator/update/) (basically, fields begins with `$`). It can lead to unexpected behaviour (see [db.collection.findOneAndReplace-upsert](https://docs.mongodb.com/v3.6/reference/method/db.collection.findOneAndReplace/#findoneandreplace-upsert) and [db.collection.update upsert behavior](https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior) for more info). Because of realization it's **strongly not recommended** using this method on collection with `sequenceId` and `updateDate` plugins.
581+
`findOneAndReplace` will be used, if update parameter do not contain any [update operators](https://docs.mongodb.com/v3.6/reference/operator/update/) (basically, fields begins with `$`). It can lead to slightly inconsistent behavior, depending on input data. (see [db.collection.findOneAndReplace-upsert](https://docs.mongodb.com/v3.6/reference/method/db.collection.findOneAndReplace/#findoneandreplace-upsert) and [db.collection.update upsert behavior](https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior) to clarify behavior difference). Because of realization it's **strongly not recommended** using this method on collection with `sequenceId` and `updateDate` plugins.
582582

583583
###### Parameters:
584584

0 commit comments

Comments
 (0)