【发布时间】:2017-07-18 19:39:23
【问题描述】:
我尝试在单击按钮时从数据库中的数组中删除 this 项目,但出现错误,我看不到我的错误。我有错误: RangeError: 超出最大调用堆栈大小,更重要的是我有 /api/editProduct/undefined
工厂:
userFactory.deleteDescription = function(description) {
return $http.delete('/api/editProduct/' + description)
}
API
router.delete('/editProduct/:description', function(req, res){
Product.findOneAndUpdate({ _id: req.body_id }, { $pull: { description: this }}, function(err, product){
if(err) throw err;
if(!product){
res.json({ success: false, message: 'No user found' });
} else {
console.log('ok')
}
});
});
型号
var productSchema = new Schema({
title: {
type: String,
require: true,
},
level: {
type: String,
require:true,
},
description: [{
type: String,
require: true,
}],
});
点是删除选择的项目
【问题讨论】:
标签: javascript node.js express mongoose