需要从数组 productid[ ] 中删除元素,这是 mongodb 集合的一个元素 用户尝试了 $pull 但似乎没有在寻求帮助
router.post('/empty-cart', isLoggedIn, function (req, res, next) {
console.log("user"+req.body.user +",product" +req.body.productId);
slug=req.body.productId;
User.update( {_id: req.body.user}, { $pull: { productId:'slug'}//this productid is array and i need to loop here
}, function(err, model){})
console.log(slug);
meanlogger.log('trash', 'Emptied cart', req.user);
res.redirect('/shopping-cart');
});