Tsallaka zuwa abun ciki
Justice Tech School

Upsert

Insert when nothing matches.

Example
db.counters.updateOne(
  { _id: "visits" },
  { $inc: { n: 1 } },
  { upsert: true }
)

Exercise

Upsert option.

{ : true }

Quiz Test

What does upsert do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.