According to MongoDB's documentation a call to save
will create a new document, or update an existing document if _id
is provided. Mongoose's documentation is less detailed and does not go into whether it will insert or update.
I am attempting to use Mongoose's save
function to update a document, but I keep getting the error:
{"error":{"name":"MongoError","code":11000,"err":"insertDocument :: caused by :: 11000 E11000 duplicate key error index: staging.participants.$_id _ dup key: { : ObjectId('5515a34ed65073ec234b5c5f') }"}}
Does Mongoose's save
function perform an upsert like MongoDB's save
function or is it just performing an insert?