db.users.updateOne({email: 'a@b.com'}, {$set: {name: 'Alice2'}})

Category: Databases & SQL

db.users.updateOne({email: 'a@b.com'}, {$set: {name: 'Alice2'}})

Update the first matching document

The $set operator changes only the named fields; without it, MongoDB replaces the entire document. updateMany applies the change to every match. Related: replaceOne for full replacement.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.