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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -