1
0

Video 76: Inserting Documents

This commit is contained in:
Jason Williams 2019-10-27 13:38:19 -06:00
parent 8dcf41320d
commit d8617bb541

View File

@ -13,8 +13,50 @@ MongoClient.connect(connectionURL, { useNewUrlParser: true }, (error, client) =>
const db = client.db(databaseName)
db.collection('users').insertOne({
name: 'Jason',
age: 38
// db.collection('users').insertOne({
// name: 'Jason',
// age: 38
// }, (error, result) => {
// if (error) {
// return console.log('Unable to insert user')
// }
//
// console.log(result.ops)
// })
// db.collection('users').insertMany([
// {
// name: 'Jen',
// age: 28
// },
// {
// name: 'Gunther',
// age: 27
// }
// ], (error, result) => {
// if (error) {
// return console.log('Unable to insert documents')
// }
//
// console.log(result.ops)
// })
db.collection('tasks').insertMany([
{
description: 'Install MongoDB',
completed: true
},{
description: 'Complete the challenge for Video 76',
completed: false
},{
description: 'Learn NodeJS',
completed: false
}
], (error, result) => {
if (error) {
return console.log('Unable to insert documents')
}
console.log(result.ops)
})
})