Skip to content

Instantly share code, notes, and snippets.

@pablocattaneo
Created January 3, 2019 13:18
Show Gist options
  • Save pablocattaneo/2ba2a2baf72aad0a0b69da411bee2a65 to your computer and use it in GitHub Desktop.
Save pablocattaneo/2ba2a2baf72aad0a0b69da411bee2a65 to your computer and use it in GitHub Desktop.
How to add next document although the previous fails in mongoDb? #mongoDb #mongoShell
db.collectionName.insertMany(
[ <document 1> , <document 2>, ... ],
{ ordered: false }
)
// Example
db.products.insertMany( [
{ _id: 10, item: "large box", qty: 20 },
{ _id: 11, item: "small box", qty: 55 },
{ _id: 11, item: "medium box", qty: 30 },
{ _id: 12, item: "envelope", qty: 100},
{ _id: 13, item: "stamps", qty: 125 },
{ _id: 13, item: "tape", qty: 20},
{ _id: 14, item: "bubble wrap", qty: 30}
], { ordered: false } )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment