Professional Documents
Culture Documents
Mongo DB NOtes
Mongo DB NOtes
To update a row
• If the row is matched in the document
db.developer.updateOne({'name':'virat'},
{$set:{
'name':'priya',
'lang':'javascript',
'member_since':5
}},{upsert:true})
-------------------------------------------------
→if the row is matched the upsertedcount=0
{
acknowledged: true,
insertedId: null,
matchedCount: 1,
modifiedCount: 1,
upsertedCount: 0
}
Note
Rename operator
➢ To change name of the row
db.developer.updateMany({name:'priya'},
{$rename:{
member:'member_since'
}}
)
----------------------------------------------------------
{
acknowledged: true,
insertedId: null,
matchedCount: 2,
modifiedCount: 2,
upsertedCount: 0
To Delete row
➢ To delete a particular row in the document.