Version 7.1.2
This release fixes the behavior of the Model.insert
and Model.create
methods when the { upsert: true }
option is provided and documents do not include an _id
field. Previously, documents would be "upserted" with { _id: null }
leading to issues.
As of this release, documents will be upserted using { _id: { $exists: false } }
as the default upsert condition when an _id
is not provided - resolving this problem.
Please be aware that using { upsert: true }
imparts a significant performance penalty on bulk inserts and should be avoided in situations where you are working with a large number of documents. The better approach is to split your document set into documents with _id
s and those without, using { upsert: true }
only for those in the former set and using { upsert: false }
for the rest.