mongodb/mongodb-update-one

Update One Document

Update a single document

mongodb
update
document

Command

db.users.updateOne({name:'Alice'}, {$set:{age:26}})

Explanation

Updates a single document matching the filter. Useful for modifying specific fields in existing records.

Examples

Update price of Laptop

db.products.updateOne({name:'Laptop'}, {$set:{price:1250}})