MongoDB - Update - Interview Questions

How do you update documents in a collection?

 

MongoDB documents can be updated using the operation db.collection.update().

For example, below operation updates the title of an employee named 'John Doe' to 'Sr Manager'

>db.employees.update(
{fname:"John", lname:"Doe"},
{$set:{ title:"Sr. Manager"}}
)
 
Subscribe to our Questions

 

MongoDB - Interview Questions

MongoDB - BasicsMongoDB - CreateMongoDB - ReadMongoDB - UpdateMongoDB - DeleteMongoDB - SearchMongoDB - AggregationMongoDB - Data ModelingMongoDB - Data ReplicationMongoDB - ShardingMongoDB - SecurityMongoDB - Administration
 
RECOMMENDED RESOURCES
Behaviorial Interview
Top resource to prepare for behaviorial and situational interview questions.

STAR Interview Example