Created
January 2, 2019 10:51
-
-
Save pablocattaneo/145ae5f5ef11c504f6c443bf556e3349 to your computer and use it in GitHub Desktop.
How to insert more than one document in mongodb? #mongoDb #mongoShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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