-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongodb.js
More file actions
30 lines (24 loc) · 781 Bytes
/
mongodb.js
File metadata and controls
30 lines (24 loc) · 781 Bytes
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
// CRUD create read update delete
const { MongoClient, ObjectID } = require('mongodb')
const connectionURL = process.env.MONGODB_CONNECTION_URL
const databaseName = 'task-manager'
MongoClient.connect(connectionURL, { useNewUrlParser: true }, (error, client) => {
if (error) {
return console.log('Unable to connect to database!')
}
const db = client.db(databaseName)
// db.collection('users').deleteMany({
// age: 27
// }).then((result) => {
// console.log(result)
// }).catch((error) => {
// console.log(error)
// })
db.collection('tasks').deleteOne({
description: "Clean the house"
}).then((result) => {
console.log(result)
}).catch((error) => {
console.log(error)
})
})