To do batch insert with Node.js MongoDB Mongoose, we call the insertMany
method.
For instance, we write
const rawDocuments = [
/* ... */
];
const mongooseDocuments = await Book.insertMany(rawDocuments);
to call the insertMany
method in the Book
schemas to insert the rawDocuments
into the database.