MongoDB – Update Document MongoDB”s update() and save() methods are used to update document into a collection. The update() method updates the values in the existing document while the save() method replaces the existing document with the document passed in save() method. MongoDB Update() Method The update() method updates the values in the existing document. […]
Author Archives: user
MongoDB – Insert Document In this chapter, we will learn how to insert document in MongoDB collection. The insert() Method To insert data into MongoDB collection, you need to use MongoDB”s insert() or save() method. Syntax The basic syntax of insert() command is as follows − >db.COLLECTION_NAME.insert(document) Example > db.users.insert({ … _id : ObjectId(“507f191e810c19729de860ea”), … […]
MongoDB – Create Collection In this chapter, we will see how to create a collection using MongoDB. The createCollection() Method MongoDB db.createCollection(name, options) is used to create collection. Syntax Basic syntax of createCollection() command is as follows − db.createCollection(name, options) In the command, name is name of collection to be created. Options is a document […]