Reputation: 1582
Can I use MongoDB's save() command with update operators like "$set"?
Or save() can be used to "update" - only while replacing all the fields (except the ID)?
Upvotes: 1
Views: 83
Reputation: 42352
No, you cannot.
$set
is an operator of an update
statement. Save is syntactic sugar that will insert a document or overwrite an existing document with entire new document.
You are likely looking for an update
operation with upsert
option set to true with $set
and possibly also $setOnInsert
operators.
Upvotes: 1