for (var i in req.body.categories) {
db.query("DELETE FROM guide_categories WHERE NOT IN($1) AND guide_id = $1",[req.body.categories[i],req.params._id], function(err, data) {
if (err) console.log(err);
console.log('updated');
})
}
I am trying to delete if not exists in the array and I am passing the array from postman like categories:["3","2","1"]
. How to do this??