In this post, the accepted answer explains that you cannot have the same fields under $set
and $setOnInsert
in an upsert operation.
Can someone explain why this is? It seems like the $setOnInsert
shouldn't conflict with $set
, since the former is used when a document is inserted, and the latter is used when the document is updated.