- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Writing a MongoDB insert statement for multiple insert at a time
For multiple insert, use insert() in MongoDB. Let us create a collection with document −
> db.demo689.insert([ ... {ClientName:"Chris","ClientAge":34,"ClientCountryName":"US"}, ... {ClientName:"David","ClientAge":28,"ClientCountryName":"UK"}, ... {ClientName:"Bob","ClientAge":39,"ClientCountryName":"AUS"}, ... ]); 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.demo689.find();
This will produce the following output −
{ "_id" : ObjectId("5ea580dfa7e81adc6a0b3967"), "ClientName" : "Chris", "ClientAge" : 34, "ClientCountryName" : "US" } { "_id" : ObjectId("5ea580dfa7e81adc6a0b3968"), "ClientName" : "David", "ClientAge" : 28, "ClientCountryName" : "UK" } { "_id" : ObjectId("5ea580dfa7e81adc6a0b3969"), "ClientName" : "Bob", "ClientAge" : 39, "ClientCountryName" : "AUS" }
- Related Articles
- How to multiple insert or batch insert at a time in MySQL query?
- Insert multiple sets of values in a single statement with MySQL?
- MongoDB bulk insert for documents
- How to insert multiple document into a MongoDB collection using Java?
- Conditional upsert (multiple insert) when updating document in MongoDB?
- Insert to specific index for MongoDB array?
- How to insert multiple rows in a table using a single INSERT command in program?
- Debugging a failed Insert statement in SAP ABAP
- Insert multiple rows in a single MySQL query
- Is there a need to insert auto_increment column values in MySQL while using INSERT statement?
- Insert a Line at Specific Line Number
- How to insert a boolean field in MongoDB?
- How to insert a Python object in Mongodb?
- MySQL - Insert current date/time?
- How to add a where clause in a MySQL Insert statement?

Advertisements