我在查询中使用运算符“$ or”。
例如find({ $or: [{ quantity: { $lt: 20 }}, { price: 10 }]})
有没有办法标记按“price:10”标准找到的记录?
答案 0 :(得分:0)
没有。返回的列表是同质的,如果找到条目是因为它们的数量少于20,或者它们的价格是10,那么你不会在该列表中知道。
只需过滤您的数组,或迭代:
var allMyEntries = find({ $or: [{ quantity: { $lt: 20 }}, { price: 10 }]});
for each entry in allMyEntries:
if entry.price == 10
//do whatever
//do something else to all of them