Or condition in mongoDB -
i use operator "$or" in query.
eg find({ $or: [{ quantity: { $lt: 20 }}, { price: 10 }]})
is there way tag records found criterion "price: 10"?
no. returned list homogeneous, not know in list if entries found because quantity less 20, or price 10.
just filter array, or iterate:
var allmyentries = find({ $or: [{ quantity: { $lt: 20 }}, { price: 10 }]}); each entry in allmyentries: if entry.price == 10 //do whatever //do else of them
Comments
Post a Comment