79177456

Date: 2024-11-11 11:29:00
Score: 2
Natty:
Report link

When the upsert parameter is true for updateOne() or findOneAndUpdate:

If no document already exist :

If matches an existing document, MongoDB only applies the $set operation.

Therefore remove the $set operation fields from $setOnInsert object and mongoDb will add them from $set object in time of creating new document

Reasons:
  • No code block (0.5):
  • Starts with a question (0.5): When the
  • Low reputation (1):
Posted by: Mahdi Movassagh