Mongoose – Insert Multiple Documents to MongoDB

To insert Multiple Documents to MongoDB using Mongoose, use Model.collection.insert(docs_array, options, callback_function); method. Callback function has error and inserted_documents as arguments.

Syntax of insert() method


  • docs is the array of documents to be inserted;
  • options is an optional configuration object – see the docs
  • callback(err, docs) will be called after all documents get saved or an error occurs. On success, docs is the array of persisted documents.


Following is an example Node.js script to demonstrate : Insert Multiple Documents to MongoDB using Mongoose.

When run using node program

Check MongoDB for the entries in bookstore collection.


Conclusion :

In this Node.js Mongoose Tutorial, we have learnt to insert multiple documents to MongoDB using Mongoose.