code: function(cb) {
        // For a basic match
        usableQueryKeys = [];
        Object.keys(query).forEach(function(k) {
          if (
            typeof query[k] === 'string' ||
            typeof query[k] === 'number' ||
            typeof query[k] === 'boolean' ||
            util.isDate(query[k]) ||
            query[k] === null
          ) {
            usableQueryKeys.push(k);
          }
        });
        usableQueryKeys = _.intersection(usableQueryKeys, indexNames);
        if (usableQueryKeys.length > 0) {
          return cb(null, self.indexes[usableQueryKeys[0]].getMatching(query[usableQueryKeys[0]]));
        }
  
        // For a $in match
        usableQueryKeys = [];
        Object.keys(query).forEach(function(k) {
          if (query[k] && query[k].hasOwnProperty('$in')) {
            usableQueryKeys.push(k);
          }
        });
        usableQueryKeys = _.intersection(usableQueryKeys, indexNames);
        if (usableQueryKeys.length > 0) {
          return cb(
            null,
            self.indexes[usableQueryKeys[0]].getMatching(query[usableQueryKeys[0]].$in),
          );
        }
  
        // For a comparison match
        usableQueryKeys = [];
        Object.keys(query).forEach(function(k) {
          if (
            query[k] &&
            (query[k].hasOwnProperty('$lt') ||
              query[k].hasOwnProperty('$lte') ||
              query[k].hasOwnProperty('$gt') ||
              query[k].hasOwnProperty('$gte'))
          ) {
            usableQueryKeys.push(k);
          }
        });
        usableQueryKeys = _.intersection(usableQueryKeys, indexNames);
        if (usableQueryKeys.length > 0) {
          return cb(
            null,
            self.indexes[usableQueryKeys[0]].getBetweenBounds(query[usableQueryKeys[0]]),
          );
        }
  
        // By default, return all the DB data
        return cb(null, self.getAllData());
      }
docs: STEP 1: get candidates list by checking indexes from most to least frequent usecase