Convert query parameters to a mongo query criteria. for example {field1:"red","field2>2":""} becomes {field1:"red",field2:{$gt:2}}
181173
function queryCriteriaToMongo(query, options) {
    var hash = {}, p, v, deep
    options = options || {}

    for (var key in query) {
        if (Object.prototype.hasOwnProperty.call(query, key) && (!options.ignore || options.ignore.indexOf(key) == -1)) {
            deep = (typeof query[key] === 'object' && !hasOrdinalKeys(query[key]))

            if (deep) {
                p = {
                    key: key,
                    value: queryCriteriaToMongo(query[key])
                }
            } else {
                p = comparisonToMongo(key, query[key])
            }

            if (p) {
                if (!hash[p.key]) {
                    hash[p.key] = p.value;
                } else {
                    hash[p.key] = Object.assign(hash[p.key], p.value);
                }
            }
        }
    }
    return hash
}
401041
def create_criteria(cls, query):
        
        criteria = []
        for name, value in query.items():
            if isinstance(value, list):
                for inner_value in value:
                    criteria += cls.create_criteria({name: inner_value})
            else:
                criteria.append({
                    'criteria': {
                        'field': name,
                        'value': value,
                    },
                })
        return criteria or None
1022858
function (query) {
        var fieldList = ['name', 'owner', 'description', 'keyword'];
        var parsedField = _.find(fieldList, function (field) {
          return query.indexOf(field + ':') === 0;
        });
        var parsedQuery = parsedField ? query.replace(new RegExp('^' + parsedField + ':'), '') : query;
        return {query: parsedQuery, field: parsedField};
      }
844464
def map_parameters(cls, params):
        """"""

        d = {}
        for k, v in six.iteritems(params):
            d[cls.FIELD_MAP.get(k.lower(), k)] = v
        return d
480256
def params
      query_string = []
      replaces = {}

      fields.each do |field|
        next if field.to_query_string.nil?
        replaces.merge!({field.digest_value => field.test_uploaded_file}) if field.is_a?(FileField)
        query_string << field.to_query_string
      end

      query_params = self.class.query_string_to_params(query_string.join('&'))

      query_params = self.class.replace_params_values(query_params, replaces)

      self.class.unescape_params(query_params)
    end
1136364
def query(options, collection_name, num_to_skip,
          num_to_return, query, field_selector, opts, check_keys=False):
    
    data = struct.pack("<I", options)
    data += bson._make_c_string(collection_name)
    data += struct.pack("<i", num_to_skip)
    data += struct.pack("<i", num_to_return)
    encoded = bson.BSON.encode(query, check_keys, opts)
    data += encoded
    max_bson_size = len(encoded)
    if field_selector is not None:
        encoded = bson.BSON.encode(field_selector, False, opts)
        data += encoded
        max_bson_size = max(len(encoded), max_bson_size)
    (request_id, query_message) = __pack_message(2004, data)
    return (request_id, query_message, max_bson_size)
997919
function(params, sep, eq) {
        var query = '',
            value,
            typeOf,
            tmpArray,
            i, size, key;

        if ( ! params) {
            return query;
        }

        sep || (sep = '&');
        eq || (eq = '=');

        for (key in params) {
            if (hasOwnProp.call(params, key)) {
                tmpArray = [].concat(params[key]);
                for (i = 0, size = tmpArray.length; i < size; ++i) {
                    typeOf = typeof tmpArray[i];

                    if (typeOf === 'object' || typeOf === 'undefined') {
                        value = '';
                    } else {
                        value = encodeURIComponent(tmpArray[i]);
                    }

                    query += sep + encodeURIComponent(key) + eq + value;
                }
            }
        }

        return query.substr(sep.length);
    }
533699
public static function criterias($params) {
        $orm = ORM::for_table($params['table']);

        foreach ($params['args'] as $arg) {
            $column = $arg[0];
            $operation = $arg[1];
            $value = $arg[2];
            
            switch($operation) {
                case '=':
                    $orm->where_equal($column, $value);
                    break;
                case '!=':
                    $orm->where_not_equal($column, $value);
                    break;
                case '>':
                    $orm->where_gt($column, $value);
                    break;
                case '>=':
                    $orm->where_gte($column, $value);
                    break;
                case '<':
                    $orm->where_lt($column, $value);
                    break;
                case '<=':
                    $orm->where_lte($column, $value);
                    break;
                case 'LIKE':
                    $orm->where_like($column, $value);
                    break;
                case 'NOT LIKE':
                    $orm->where_not_like($column, $value);
                    break;
            }
        }

        return $orm;
    }
531952
def filter_query(key, expression):
    """"""
    if (isinstance(expression, dict)
            and len(expression) == 1
            and list(expression.keys())[0].startswith('$')):
        compiled_expression = compile_query(expression)
    elif callable(expression):
        def _filter(index, expression=expression):
            result = [store_key
                      for value, store_keys in index.get_index().items()
                      if expression(value)
                      for store_key in store_keys]
            return result
        compiled_expression = _filter
    else:
        compiled_expression = expression

    def _get(query_function, key=key, expression=compiled_expression):
        """Get document key and check against expression."""
        return query_function(key, expression)

    return _get
995645
function(req) {
    var fields = {};

    // Fields
    if (_.isString(req.query.fields)) {
      _.forEach(req.query.fields.split(','), function(field) {
        fields[field] = 1;
      });
    }

    return fields;
  }
1680
def filter_by(self, **kwargs):
        
        query = self._copy()
        for field, value in kwargs.items():
            query.domain.append(
                (field, '=', value)
            )
        return query
784149
def gql(query_string, *args, **kwds):
  
  qry = _gql(query_string)
  if args or kwds:
    qry = qry._bind(args, kwds)
  return qry
978042
function (qs, options) {

            debug('Extracting items...');

            qs = qs + '';

            debug('Separator: %s', options.separator);

            // split query string parameters on separator (default is: '&')
            const items = qs.split(options.separator, Number.MAX_SAFE_INTEGER);
            debug('Items: %o', items);

            return items;
        }
367529
def _validate_rel(param, rels):
    

    if param.field.count('/') > 1:
        raise InvalidQueryParams(**{
            'detail': 'The filter query param of "%s" is attempting to '
                      'filter on a nested relationship which is not '
                      'currently supported.' % param,
            'links': LINK,
            'parameter': PARAM,
        })
    elif '/' in param.field:
        model_field = param.field.split('/')[0]

        if model_field not in rels:
            raise InvalidQueryParams(**{
                'detail': 'The filter query param of "%s" is attempting to '
                          'filter on a relationship but the "%s" field is '
                          'NOT a relationship field.' % (param, model_field),
                'links': LINK,
                'parameter': PARAM,
            })
975891
def prepare_query_params(**kwargs):
    
    return [
        (sub_key, sub_value)
        for key, value in kwargs.items()
        for sub_key, sub_value in expand(value, key)
        if sub_value is not None
    ]
828025
function query(q) {
  var filter = Object.keys(q);
  var isValid;
  var valid;
  var val;

  return this.reduce((list, ps) => {
    isValid = filter.every(key => {
      val = q[key];
      valid = true;

      if (typeof val === 'string') {
        if (val.indexOf('<') > -1) {
          valid = ps[key] < cleanValue(val, '<');
        }

        if (valid && val.indexOf('>') > -1) {
          valid = ps[key] > cleanValue(val, '>');
        }

        if (valid && val.indexOf('~') > -1) {
          valid = ps[key].indexOf(q[key].replace('~', '')) > -1;
        }
      } else {
        valid = ps[key] === val;
      }

      return valid;
    });

    if (isValid) list.push(ps);

    return list;
  }, []);
}
250195
def _validate_field(param, fields):
    

    if param.field not in fields:
        raise InvalidQueryParams(**{
            'detail': 'The sort query param value of "%s" is '
                      'invalid. That field does not exist on the '
                      'resource being requested.' % param.raw_field,
            'links': LINK,
            'parameter': PARAM,
        })