Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pablocattaneo/145ae5f5ef11c504f6c443bf556e3349 to your computer and use it in GitHub Desktop.
Save pablocattaneo/145ae5f5ef11c504f6c443bf556e3349 to your computer and use it in GitHub Desktop.
How to insert more than one document in mongodb? #mongoDb #mongoShell
db.collectionName.insertMany( [ <document 1> , <document 2>, ... ])
// example
db.patients.insertMany([{
"firstName": "Max",
"lastName": "Martinez",
"age": 29,
"history": [{
"disease": "cold",
"treatment": "Drink strange thinks"
}, {
"disease": "headache",
"treatment": "Work less"
}]
}, {
"firstName": "Pedro",
"lastName": "Cattaneo",
"age": 15,
"history": [{
"disease": "stomach ache",
"treatment": "stop eating fast food"
}]
}, {
"firstName": "Maria",
"lastName": "McCartney",
"age": 45,
"history": [{
"disease": "indigestion",
"treatment": "stop watching tv durin the lunch"
}]
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment