title: field must be of BSON type object
body: <p>I am creating a dynamic filter object for querying data from mongodb in nodejs. However mongo throws error "Failed to parse filter object, filter must be of BSON type object". Here is my reference function code and <a href="https://i.stack.imgur.com/sCllY.png" rel="noreferrer">screen shot of logs</a>.</p>
  
  <pre><code>function GetDeviceByFilter(args, cb) {
    var query = args.qs;
    var andQry = [];
    var orQry = [];
    var type = parseInt(query.type);
    try {
      if(type === uType.s){
        andQry.push({sel: parseInt(query.idx)});
        if(query.isSold === "0"){
          orQry.push({uid: {$exists: false}})
          orQry.push({uid: 0});
          orQry.push({uid: null});
        } else if(query.isSold === "1"){
          orQry.push({uid : {$gt: 0}});
        }
      } else if(type === uType.a){
        andQry.push({admn: parseInt(query.idx)});
        if(query.isSold === "0"){
          orQry.push({sel: {$exists: false}})
          orQry.push({sel: 0});
          orQry.push({sel: null});
        } else if(query.isSold === "1"){
          orQry.push({sid : {$gt: 0}});
        }
      }
      logger.debug("And filter ", JSON.stringify(andQry));
      logger.debug("or filter ", JSON.stringify(orQry));
    } catch (e) {
      logger.error(e);
    }
    var filter = [];
    filter.push({$and: andQry});// = [$and : {andQry}, {$or: orQry}];
    logger.debug("filter : ",filter);
    var projections = {
      uuid: 1,
      mac: 1,
      sim: 1,
      imei: 1,
      _id: 0
    };
    dbClient.FindDocFieldsByFilter(devCollection, filter, projections, 0,
      function(e, d) {
        if(e) logger.error(e)
        cb(d, retCode.ok);
      });
  }
  </code></pre>
  
  <p>Tons of thanks in advance.</p>