To save multiple documents concurrently in Mongoose and Node.js, we call the create method.
For instance, we write
const array = [{ type: "jelly bean" }, { type: "snickers" }];
Candy.create(array, (err, jellybean, snickers) => {
if (err) {
//...
}
});
to call the create method with the array to write the entries into the collection.
And then we get the written entries from the parameters after err.
err is the error if there is any.