0
我有一个文件“集合”的对象:猫鼬发现,并从数组中删除一个文件
{
name: {type: String, required: true, default: "Untitled Collection"},
movies: [
{ the_id: {type: String},
movie_id: {type: String},
tmdb_id: {type: String},
original_title: {type: String},
release_date: {type:Date}
}],
author: {type: String},}
我需要找到和动画[]删除特定项目。这是我目前所拥有的,并且不起作用。
req.body是通过POST请求的数据传递的对象,并且具有所有必要的,以便能够匹配一个在电影[]数组
Collection.findOne({_id : req.params.id}, (err, collection) =>{
if(err){res.status(400).json(err);}
if(!collection)
{
res.status(404).json({message: 'No collection found'});
}else{
collection.movies.pop(req.body);
collection.save();
res.json(collection);
}
});
所有它目前所做的是弹出关闭信息阵列中的前方对象,但我需要它来除去,其等于阵列中的对象到req.body