1
0
CompleteNodeJS/task-manager/playground/promise-chaining-2.js
2020-02-23 16:46:50 -07:00

24 lines
617 B
JavaScript

require('../src/db/mongoose')
const Task = require('../src/models/task')
// Task.findByIdAndDelete('5e52f573b7d229017fe21321').then((task) => {
// console.log(task)
// return Task.countDocuments({ completed: false })
// }).then((result) => {
// console.log(result)
// }).catch((e) => {
// console.log(e)
// })
const deleteTaskAndCount = async (id) => {
const task = await Task.findByIdAndDelete(id)
const count = await Task.countDocuments({ completed: false })
return count
}
deleteTaskAndCount('5e489156e9232d006872395e').then((count) => {
console.log(count)
}).catch((e) => {
console.log(e)
})