我有这篇文章在我的收藏中:
{
"_id" : ObjectId("52718433e18a711923000005"),
"owners" : [
ObjectId("52718433e18a711923000004"),
ObjectId("52ed40dccc5bc50000000003"),
ObjectId("52ed4171abe2780000000003")
]
}
我有以下陈述,我试图从owners
字段中删除一个值:
Business.update({_id:req.body._id}, {$pull:{"owners":req.body.userid}}, function(err){
if(err){
res.json(500, {message:"Could not remove user from admin list"});
}else{
res.json(200);
}
});
我知道req.body._id
和req.body.userid
有合法的值:
{ _id: '52718433e18a711923000005',
userid: '52ed4171abe2780000000003' }
其他操作,例如通过ID查找业务等都可以正常工作,因此这不是一个ObjectId格式问题。还可能是什么原因呢?
-- 编辑:这是我的(缩写的)模式定义:
var BusinessSchema = new Schema({
business_name: {type: String, required: true},
owners: {type: Array}
});