Transforms query request object

@param queryOptions
@returns {*}
775707
function queryRequest(queryOptions) {

    if (!queryOptions) {
        return;
    }

    var options = util._extend({}, queryOptions);

    if (options.query && options.query.length) {
        options.query = '&sq=' + encodeURIComponent(options.query);
    }

    if (options.sort) {
        options.orderBy = '&orderby=column:' + options.sort;
        delete options.sort;
    }

    if (options.descending) {
        options.reverse = '&reverse=true';
        delete options.descending;
    }

    return options;
}
659900
def _parse_api_options(self, options, query_string=False):
        
        api_options = self._select_options(options, self.API_OPTIONS)
        if query_string:
            # Prefix all options with "opt_"
            query_api_options = {}
            for key in api_options:
                # Transform list/tuples into comma separated list
                if isinstance(api_options[key], (list, tuple)):
                    query_api_options[
                        'opt_' + key] = ','.join(api_options[key])
                else:
                    query_api_options[
                        'opt_' + key] = api_options[key]
            return query_api_options
        else:
            return api_options
772835
function query (options$$1, next) {

    var urlParams = Object.keys(Url.options.params), query = {}, url = next(options$$1);

    each(options$$1.params, function (value, key) {
        if (urlParams.indexOf(key) === -1) {
            query[key] = value;
        }
    });

    query = Url.params(query);

    if (query) {
        url += (url.indexOf('?') == -1 ? '?' : '&') + query;
    }

    return url;
}
713106
function QueryString (qs) {
        var parts = qs.split('&');

        for (var i = 0, s = parts.length; i < s; i++) {
            var keyVal = parts[i].split('=');
            var key = decodeURIComponent(keyVal[0].replace(RX_PLUS, ' '));

            if (!key) {
                continue;
            }

            var value = keyVal[1] !== undefined ? decode(keyVal[1]) : null;

            if (typeof this[key] === 'undefined') {
                this[key] = value;
            } else {
                if (!(this[key] instanceof Array)) {
                    this[key] = [this[key]];
                }

                this[key].push(value);
            }
        }
    }
516671
function queryParser( req, res, next ) {
	if ( !req.query ) {
		var val = parseUrl( req ).query;
		req.query = queryparse( val );
	}
	next();
}
324020
@InterfaceAudience.Private
    public List<QueryRow> query(QueryOptions options) throws CouchbaseLiteException {
        if (options == null)
            options = new QueryOptions();
        if (groupOrReduce(options))
            return viewStore.reducedQuery(options);
        else
            return viewStore.regularQuery(options);
    }
1149076
function(options) {
        var params = {
          skip: this._skip,
          limit: this._limit,
        };

        return request({
          path: `/bigquery/jobs/${this.id}`,
          method: 'GET',
          query: params,
          authOptions: options,
          signKey: false,
        }).then(function(response) {
          if (response.error) {
            return Promise.reject(new AVError(response.code, response.error));
          }
          return Promise.resolve(response);
        });
      }
114795
function appendQueryStringOptions(requestUrl, queryStringOptions) {
    requestUrl += "?";
    for (var prop in queryStringOptions) {
        if (queryStringOptions.hasOwnProperty(prop)) {
            requestUrl += prop + "=" + queryStringOptions[prop] + "&";
        }
    }

    //Remove the last & from the string
    requestUrl = requestUrl.substr(0, requestUrl.length - 1);
    return requestUrl;
}
141357
function mergeQueries(query, options) {
  if (options == null) {
    return query;
  }

  Object.keys(options).forEach(key => {
    let label = key;
    let value = options[key];

    validateProp(key, value);

    switch (key) {
    case 'orderByKey':
      label = orderedBy;
      value = orderByKey;
      break;

    case 'orderByPriority':
      label = orderedBy;
      value = orderByPriority;
      break;

    case 'orderByValue':
      label = orderedBy;
      value = orderByValue;
      break;

    case 'orderByChild':
      label = orderedBy;
      break;

    default:
      break;
    }

    query[label] = value;
  });

  return query;
}
328582
function(filterIndex, options) {
      if (options === undefined) {
        throw new Error('Request filter at index ' + filterIndex + ' returned nothing; it must return the filtered request options');
      } else if (!_.isObject(options)) {
        throw new Error('Expected request filter at index ' + filterIndex + ' to return the request options as an object, got ' + typeof(options));
      }

      return options;
    }
156565
function modelQuery(options) {
            return models.Post.findPage(options)
                .then(({data, meta}) => {
                    return {
                        posts: data.map(model => urlsForPost(model.id, model.toJSON(options), options)),
                        meta: meta
                    };
                });
        }
358998
function getRawPendingTransactions (queryOptions) {
  return sendQuery(
    queryOptions,
    queryHelper.addQuery(
      queryHelper.emptyQuery(),
      'getPendingTransactions',
      {}
    ),
    (resolve, reject, responseName, response) => {
      if (responseName !== 'TRANSACTIONS_RESPONSE') {
        const error = JSON.stringify(response.toObject().errorResponse)
        return reject(new Error(`Query response error: expected=TRANSACTIONS_RESPONSE, actual=${responseName}\nReason: ${error}`))
      }

      const transactions = response.getTransactionsResponse()
      resolve(transactions)
    }
  )
}
1155084
function coerceQueryParamsToString(queryParams) {
    for (var key in queryParams) {
      if (typeof queryParams[key] === 'number') {
        queryParams[key] = '' + queryParams[key];
      } else if (isArray(queryParams[key])) {
        for (var i = 0, l = queryParams[key].length; i < l; i++) {
          queryParams[key][i] = '' + queryParams[key][i];
        }
      }
    }
  }
554288
function queryState(defaults, options) {
  options = options || {};
  var history = options.history || windowHistory(defaults, options);
  validateHistoryAPI(history);

  history.onChanged(updateQuery)

  var query = history.get() || Object.create(null);

  var api = {

    /**
     * Gets current state.
     *
     * @param {string?} keyName if present then value for this key is returned.
     * Otherwise the entire app state is returned.
     */
    get: getValue,

    /**
     * Merges current app state with new key/value.
     *
     * @param {string} key name
     * @param {string|number|date} value
     */
    set: setValue,

    /**
     * Removes value from the query string
     */
    unset: unsetValue,

    /**
     * Similar to `set()`, but only sets value if it was not set before.
     *
     * @param {string} key name
     * @param {string|number|date} value
     */
    setIfEmpty: setIfEmpty,

    /**
     * Releases all resources acquired by query state. After calling this method
     * no hash monitoring will happen and no more events will be fired.
     */
    dispose: dispose,

    onChange: onChange,
    offChange: offChange,

    getHistoryObject: getHistoryObject,
  }

  var eventBus = eventify({});

  return api;

  function onChange(callback, ctx) {
    eventBus.on('change', callback, ctx);
  }

  function offChange(callback, ctx) {
    eventBus.off('change', callback, ctx)
  }

  function getHistoryObject() {
    return history;
  }

  function dispose() {
    // dispose all history listeners
    history.dispose();

    // And remove our own listeners
    eventBus.off();
  }

  function getValue(keyName) {
    if (keyName === undefined) return query;

    return query[keyName];
  }

  function setValue(keyName, value) {
    var keyNameType = typeof keyName;

    if (keyNameType === 'object') {
      Object.keys(keyName).forEach(function(key) {
        query[key] = keyName[key];
      });
    } else if (keyNameType === 'string') {
      query[keyName] = value;
    }

    history.set(query);

    return api;
  }

  function unsetValue(keyName) {
    if (!(keyName in query)) return; // nothing to do

    delete query[keyName];
    history.set(query);

    return api;
  }

  function updateQuery(newAppState) {
    query = newAppState;
    eventBus.fire('change', query);
  }

  function setIfEmpty(keyName, value) {
    if (typeof keyName === 'object') {
      Object.keys(keyName).forEach(function(key) {
        // TODO: Can I remove code duplication? The main reason why I don't
        // want recursion here is to avoid spamming `history.set()`
        if (key in query) return; // key name is not empty

        query[key] = keyName[key];
      });
    }

    if (keyName in query) return; // key name is not empty
    query[keyName] = value;

    history.set(query);

    return api;
  }
}
818
function filterOutOptionalQueryParams(data) {
  data.queryParameters = data.queryParameters.filter(function(queryParam) {
    // Let's be conservative and treat params without explicit required field as not-optional
    var optional = queryParam.required !== undefined && !queryParam.required;
    var dataProvided = data.requestParameters.hasOwnProperty(queryParam.name);

    return !optional || dataProvided;
  });
  return data;
}
221943
function querystring(query) {
  var parser = /([^=?&]+)=?([^&]*)/g
    , result = {}
    , part;

  while (part = parser.exec(query)) {
    var key = decode(part[1])
      , value = decode(part[2]);

    //
    // Prevent overriding of existing properties. This ensures that build-in
    // methods like `toString` or __proto__ are not overriden by malicious
    // querystrings.
    //
    if (key in result) continue;
    result[key] = value;
  }

  return result;
}
1207654
def query_sort(query, options)
      query.order(options[:order]) if options[:order]
      query.order(options[:desc_order], :desc) if options[:desc_order]
      query
    end