update Archive

mongoDB – Upserts – insert or update a document

If we use update command the document is updated only if that document record is present in collection. But if the requirement is that if document is present then we update it otherwise insert it as a new record. Then we can use upsert command. Suppose we run an update command as follows  > db.users.update({"name":"mike"},{$set:{$age:

MongoDB – Insert, Update, Delete and Read

MongoDB stores data in form of documents  are JSON like key Рvalue pairs.