-
Notifications
You must be signed in to change notification settings - Fork 0
/
week03s.js
64 lines (61 loc) · 1.58 KB
/
week03s.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { MongoClient, ServerApiVersion, ObjectId } = require('mongodb');
const uri = "mongodb+srv://m001-student:p4ssw0rd@sandbox.epk5x.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
client.connect(async err => {
if (err) {
console.log(err.message)
return
}
console.log('Connected to MongoDB');
console.time('insert');
let result = await client.db('Week03').collection('companies').deleteMany({
name: 'Zenfolio'
})
// let result = await client.db('Week03').collection('companies').updateOne(
// { name: 'utem' },
// { $set: { address: 'Zenfolio Inc.' } },
// { upsert: true }
// )
// let result = await client.db('Week03').collection('companies').insertMany([
// {
// name: 'Zenfolio',
// address: {
// street: '123 Main St',
// city: 'New York',
// state: 'NY',
// zip: '10001'
// }
// },
// {
// name: 'Google',
// address: {
// street: '1600 Amphitheatre Pkwy',
// city: 'Mountain View',
// state: 'CA',
// zip: '94043'
// }
// }
// ])
// client.db('Week03').collection('companies').insertOne({
// name: 'Zenfolio',
// address: {
// street: '123 Main St',
// city: 'New York',
// state: 'NY',
// zip: '10001'
// },
// employees: [
// {
// name: 'John',
// age: 25,
// position: 'CEO'
// },
// ]
// }).then(result => {
// console.timeEnd('insert');
// console.log(result);
// })
console.timeEnd('insert');
console.log(result);
console.log('completed')
});