I work with mongodb 3.2 I can not do a search on several fields. for example, in yii it was easier:
$command = Yii->createCommand($sql) if ($one) $command->addCondition($cond1); if ($two) $command->addCondition($cond2); $result = $command->queryAll(); and in mongodb it turns out only 1 time you can set the parameters, and then the search starts
db.coll.find({}); I would like this:
curs = myColl.find(); if(cond1) { curs2 = curs.find({cond2}) } that is, we will move hierarchically, adding filtering filters as we go.
PS: I write API, for some reason, $ where it does not plow from me .. (meteor 1.3, nimble / restivus)
UPD
{ "_id" : "u5QYDyrbXn24FYaQD", "baseFields" : { "carCatId" : "yCHznKsJaMjL3dzTM", "carClassId" : "c69tHZHGWyxLDthkL", "carClassTplId" : 4, "carMarkaId" : "76Xme6nPQyaLQST9g", "carGosNomer" : "Z 123", "carProductionYear" : "2010", "carHourlyPrice" : "5000" }, "extraFields" : { "carKubatura" : "2000", "carTonna" : "5000" } } { "_id" : "H53hpx6mBPrWPTPCB", "baseFields" : { "carCatId" : "ye3DNu482L9uGeMqk", "carClassId" : "4sf3eXAcqmLe7XysY", "carClassTplId" : 3, "carMarkaId" : "i3BKrpJf4baLYo8Ky", "carGosNomer" : "LLL", "carProductionYear" : "2010", "carHourlyPrice" : "5000" }, "extraFields" : { "carSeats" : "4", "carColor" : "1" } }
trying to find like this:
var cond = {'baseFields':{}}; cond.baseFields.carCatId = 'yCHznKsJaMjL3dzTM'; db.mycoll.find(cond);