Tag Archives: Mongo Document

MongoDB Insert Document

This post will help us to learn How to add document in the MongoDB collection. MongoDB has `insert()` and `save()` method to add a document into collection. Syntax: db.COLLECTION_NAME.insert(document) Insert Single record: Example: > use learnmongodb switched to db learnmongodb > db.books.insert({ ‘title’:’MongoDB’, ‘description’:’Learn MongoDB with NoSQL’, ‘version’:’4.x’ }) WriteResult({ “nInserted” : 1 }) [OR] […]

MongoDB Query Document

This tutorial will help you to get a clear understanding to use the query operations using the db.collection.find() function. Sample Collection Query Documents Query on Embedded/Nested Documents Query an Array Query an Array of Embedded Documents Sample Collection I am going to use the below `books` collection for all the sample query. db.books.insertMany([ { “name” […]