【发布时间】:2015-08-17 17:40:42
【问题描述】:
我的代码以 60 秒到 2 分钟的间隔一次又一次地运行。这个 put 函数需要能够从多个数组中动态拉取数据。我把它缩小到只发生在服务器端,客户端的功能永远不会触发,但服务器端将继续运行。有谁知道为什么会发生这种情况?我尝试了“update”、“findByIdAndUpdate”和“findById”,结果都一样。
router.put('/updateDeleteProducts', function(req, res, next){
console.log("Here is the delete info: ", req.body);
var size = req.body.size;
var pictures = req.body.picture;
var outerfabric = req.body.outerfabric;
var innerfabric = req.body.innerfabric;
var armlength = req.body.armlength;
var backlength = req.body.backlength;
var updates = {
$pull: {updated:true}
};
if (req.body.size != undefined){
updates.$pull.size = size;
}
if (req.body.picture != undefined){
updates.$pull.pictures = pictures;
}
if (req.body.outerfabric != undefined){
updates.$pull.outerfabric = outerfabric;
}
if (req.body.innerfabric != undefined){
updates.$pull.innerfabric = innerfabric;
}
if (req.body.armlength != undefined){
updates.$pull.armlength = armlength;
}
if (req.body.backlength != undefined){
updates.$pull.backlength = backlength;
}
console.log("Here are the variables to be deleted: ", updates);
Products.update({_id: req.body._id}, updates, function(err, data){
if (err) next(err);
console.log("DELETE Callback Data: ",data);
});
});
【问题讨论】:
标签: node.js mongodb express mongoose