MongoDB - $in and $or operator
$in operator : It match a value within the specified values within the given values.
e.g. If we want to select record which credit score is (1200 and 2000).
db.collection.find({"creditscore" :{$in :[1200,2000]}}).pretty();
$or operator: It match whether any of the specified value is matching in the given records.
e.g. If we want to select record which either belongs to color 'red' or grade 'C'.
db.collection.find({$or : [ { "color" : 'red' } , { "grade" : "C" } ] } ).pretty();
0 Comment(s)