mongodb - Matching Rules w/ Mongo -
i trying compare objects collection of rules stored in mongo. here example of object , 2 rules:
object: { "color": "red" ,"make": "ford" ,"type": "sedan" }
rules: [0]{ "color": "red" ,"type": "suv" } [1]{ "make": "ford" }
in example, rule 1 should match. have played around different operators ($exists, $or, $and) have had no luck making results match solution working on. great. thanks!
i didn't have trouble matching 1 of rules using $or operator:
> db.obj.insert({ "color": "red" ,"make": "ford" ,"type": "sedan" }) inserted 1 record(s) in 17ms > db.obj.find({$or:[{color:"red", "type":"suv"}, {make:"ford"}]}) { "_id" : objectid("518ac9be6c49c38046ac4b19"), "color" : "red", "make" : "ford", "type" : "sedan" } >
Comments
Post a Comment