2019-10-27 19:18:36 +00:00
|
|
|
// CRUD create read update delete
|
|
|
|
|
2019-10-28 00:40:26 +00:00
|
|
|
const { MongoClient, ObjectID } = require('mongodb')
|
2019-10-27 19:18:36 +00:00
|
|
|
|
|
|
|
const connectionURL = 'mongodb://127.0.0.1:27017'
|
|
|
|
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)
|
|
|
|
|
2020-02-15 19:30:03 +00:00
|
|
|
// db.collection('users').deleteMany({
|
|
|
|
// age: 38
|
2020-02-15 19:21:22 +00:00
|
|
|
// }).then((result) => {
|
|
|
|
// console.log(result)
|
|
|
|
// }).catch((error) => {
|
|
|
|
// console.log(error)
|
2019-10-27 19:38:19 +00:00
|
|
|
// })
|
|
|
|
|
2020-02-15 19:30:03 +00:00
|
|
|
db.collection('tasks').deleteOne({
|
|
|
|
description: 'Install MongoDB'
|
2020-02-15 19:21:22 +00:00
|
|
|
}).then((result) => {
|
2020-02-15 19:30:03 +00:00
|
|
|
console.log(result)
|
2020-02-15 19:21:22 +00:00
|
|
|
}).catch((error) => {
|
|
|
|
console.log(error)
|
2019-10-27 19:18:36 +00:00
|
|
|
})
|
|
|
|
})
|