猫鼬-在一个函数调用中删除多个文档 [英] Mongoose - remove multiple documents in one function call
本文介绍了猫鼬-在一个函数调用中删除多个文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在文档中有deleteMany()方法
In documentation there's deleteMany() method
Character.deleteMany({ name: /Stark/, age: { $gte: 18 } }, function (err) {});
我要删除具有一个公共属性而另一个属性不同的多个文档.像这样:
I want to remove multiple documents that have one common property and the other property vary. Something like this:
Site.deleteMany({ userUID: uid, id: [10, 2, 3, 5]}, function(err)
{}
正确的语法是什么?
推荐答案
我相信您要寻找的是$in
运算符:
I believe what youre looking for is the $in
operator:
Site.deleteMany({ userUID: uid, id: { $in: [10, 2, 3, 5]}}, function(err) {})
此处的文档: https://docs.mongodb.com/manual/参考/操作员/查询/输入/
这篇关于猫鼬-在一个函数调用中删除多个文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文