如何找到与Mongoose中的查询列表匹配的所有文档?
例如,模型Person看起来像:
{
name,
lastname,
...
}
如果我需要找到像John Doe这样的特定人物,Alice Lorem,Bob Ipsum,是否可以在一个find()命令中找到它?
像
这样的东西Person.find([{name: "John", lastname: "Doe"},
{name: "Alice", lastname: "Lorem"},
{name: "Bob", lastname: "Ipsum"}]);
帮助!
答案 0 :(得分:3)
$or
逻辑查询运算符是您所需要的。
Dropzone.options.myZone = {
paramName: "file",
acceptedFiles: "image/jpeg, image/png, image/gif, .mp3, .pdf, .zip",
autoProcessQueue: true,
addRemoveLinks: true,
removedfile: function (file) {
var name = file.name;
$.ajax({
type: 'POST',
url: 'media/remove',
data: {"name": name},
dataType: 'html'
});
$(document).find(file.previewElement).fadeOut(400, function () {
this.remove();
if ($('.dz-preview').length < 1) {
$('form').removeClass("dz-started");
}
})
}
}
});
答案 1 :(得分:1)
您可以使用Query.or
:
Person.find().or([
{name: "John", lastname: "Doe"},
{name: "Alice", lastname: "Lorem"},
{name: "Bob", lastname: "Ipsum"}
]).exec(...)