
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Perform Bulk insert in MongoDB?
For bulk insert in MongoDB, use initializeUnorderedBulkOp(). Let us create a collection with documents −
> var bulkInsertDoc = db.demo663.initializeUnorderedBulkOp(); > bulkInsertDoc.insert( { Name: "John",CountryName:"US"} ); > bulkInsertDoc.insert( { Name: "Chris",CountryName:"UK"} ); > bulkInsertDoc.insert( { Name: "David",CountryName:"AUS"} ); > bulkInsertDoc.execute(); BulkWriteResult({ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 3, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] })
Display all documents from a collection with the help of find() method −
> db.demo663.find();
This will produce the following output −
{ "_id" : ObjectId("5ea1b41424113ea5458c7d05"), "Name" : "John", "CountryName" : "US" } { "_id" : ObjectId("5ea1b41424113ea5458c7d06"), "Name" : "Chris", "CountryName" : "UK" } { "_id" : ObjectId("5ea1b41424113ea5458c7d07"), "Name" : "David", "CountryName" : "AUS" }
- Related Articles
- MongoDB bulk insert for documents
- Perform multiple updates with bulk operations and update elements in an array in MongoDB
- Perform aggregation sort in MongoDB?
- Perform simple validation in MongoDB?
- Insert in MongoDB without duplicates
- Bulk Reading in Cassandra
- Perform complex MySQL insert by using CONCAT()?
- How to insert Date in MongoDB?
- Perform MongoDB full text search
- Perform conditional upserts or updates in MongoDB
- Perform nested document value search in MongoDB?
- How to insert LONG numbers in MongoDB?
- Insert data into inner array in MongoDB?
- Perform min/max with MongoDB aggregation
- How to perform ascending order sort in MongoDB?

Advertisements