Upsert
Insert when nothing matches.
Example
db.counters.updateOne(
{ _id: "visits" },
{ $inc: { n: 1 } },
{ upsert: true }
)Exercise
Upsert option.
{ : true }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.