MongoDB upsert

MongoDB upsert

MongoDB 02-03-2023 Saheb Sutradhar

 

MongoDB upsert

 

 

upsert = update + insert

If the name matches then it will update the document else add new document

db.collection.updateOne( { name: "codelearningpoint" },{ $set : {age:"2 years" , type:"Blog" } },{upsert : true} )

 

 

 

Related Posts

Card image cap

MongoDB Basic and CRUD Operations

MongoDB 02-09-2022 Saheb Sutradhar

MongoDB Basic and CRUD Operations ...

Card image cap

MongoDB Read Array Document

MongoDB 05-02-2023 Saheb Sutradhar

MongoDB Read Array Document ...

Card image cap

MongoDB read operation findOne() and find()

MongoDB 05-02-2023 Saheb Sutradhar

MongoDB read operation findOne() and find() ...

Card image cap

MongoDB $unset

MongoDB 02-03-2023 Saheb Sutradhar

MongoDB $unset ...

Card image cap

MongoDB $rename

MongoDB 02-03-2023 Saheb Sutradhar

MongoDB $rename ...

Card image cap

MongoDB array update operation

MongoDB 13-03-2023 Saheb Sutradhar

MongoDB array update operation ...