I have this function:
remove(data.toString())
function remove(node){
Item.findByIdAndDelete(node).then(()=>{
Item.find({parent: mongoose.Types.ObjectId(node)}).select('_id').then((d)=>{
d.forEach(e => {
remove(e._id)
});
})
})
}
I would like to promisify it so that I can call:
remove(data.toString()).then(()=>{console.log('done')})
how can I achieve this? any help would be greatly apprectiated!