-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo.js
executable file
·42 lines (35 loc) · 1016 Bytes
/
mongo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//testing mongo
const mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;
const connectionURL = 'mongodb://127.0.0.1:27017';
var databaseName = 'task-manager';
MongoClient.connect(connectionURL, { useNewUrlParser: true }, function(err, client) {
if (err) {
return console.log('unable to connect');
}
var db = client.db(databaseName);
// db.collection('users').insertMany([{
// name: 'jayden',
// age: 36,
// }], (err, result) => {
// if (err) {
// return console.log('unable to connect');
// }
// console.log(result.ops);
// })
db.collection('tasks').insertMany([{
description: 'coding',
competed: false,
}, {
description: 'playing',
competed: false,
}, {
description: 'dancing',
competed: true,
}], (err, result) => {
if (err) {
return console.log('unable to connect');
}
console.log(result.ops);
})
});