我试图让find返回所有匹配的文档,其中orderStatus是'Pending'或'In Progress',执行此查询的最简单方法是什么?非常感谢!
MyCollection.find({ user: currentUserId,
{ $or:
[{orderStatus : "Pending"},
{orderStatus : "In Progress"}] }});
答案 0 :(得分:0)
使用 $in
运算符,如下所示:
MyCollection.find({
"user": currentUserId,
"orderStatus": { "$in": ["Pending", "In Progress"] }
});
以上查询是使用 $or
运算符的以下查询的更简单版本:
MyCollection.find({
"user": currentUserId,
"$or": [
{ "orderStatus": "Pending" },
{ "orderStatus": "In Progress" }
]
});