Upserts and Replacing a Whole Document
An upsert updates a document when the filter finds one and inserts it when it doesn't, $setOnInsert sets values only on that first insert, replaceOne swaps in a whole new version, and findOneAndUpdate changes a document and hands it back.
Updated

- Category
- MongoDB
- Level
- Journeyman
- Tags
- $setOnInsert, findOneAndUpdate, mongodb, replaceOne, Upsert