insertMany()
Inserts an array of items into database. If items passed in do not contain the **_id** field, one will be added to each of the items missing it
Example
db.collection("users").insertMany([
{a: "123"},
{b: "456"},
{c: "789"}
]).then(() => {
//Items inserted in db;
/*
example output => [
{
"_id": "m0i1s85b9cui2qr4ys8bqvl8wczr51em",
"a": "123"
},
{
"_id": "1n608o008q24ul39ssyqniq5b9i33cx7",
"b": "456"
},
{
"_id": "3cfp5p75x5vi1hk9cly140zgy1fs50g7",
"c": "789"
}
]
*/
}).catch(error => {
console.log("error:", error);
});
insertMany(Array<Object>)
Last updated
Was this helpful?