Mongo Document Tutorials

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 CollectionQuery DocumentsQuery on Embedded/Nested DocumentsQuery an ArrayQuery an Array of Embedded DocumentsSample CollectionI am going to use the below `books` collection for all the sample query. db.books.insertMany([ { "name" : "The Little Prince", "author" : { "name" : "Antoine de Saint-Exupery", "born" : 1900, "died" : 1944, "occupation" : ["Aviator", "writer"] […]... Read More »

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] > db.books.insertOne({ 'title':'MongoDB', 'description':'Learn MongoDB with NoSQL', 'version':'4.x' }) { "acknowledged" : true, "insertedId" : ObjectId("5b8e859670e393ef22ee63ed") } > […]... Read More »