docs: function collectQueryParams(req, paramNames) {
      var result = {
          query: {},
          fields: {},
          options: {},
          params: {}
      };
      paramNames.forEach(function (paramName) {
          var paramValue = req.anyParam(paramName);
          if (paramValue) {
              paramValue = paramValue.trim();
              if (paramValue && paramValue !== '*') {
                  if (paramValue.charAt(paramValue.length - 1) === '*') {
                      // regexp to match prefix
                      paramValue = new RegExp('^' + paramValue.substring(0, paramValue.length - 1));
                  }
                  result.query[paramName] = paramValue;
              }
              result.params[paramName] = paramValue;
          }
      });
      var fields = req.anyParam('fields');
      if (fields) {
          result.fields = {};
          fields.split(',').forEach(function (field) {
              field = field.trim();
              if (field) {
                  var select = 1;
                  switch (field.charAt(0)) {
                      case '-':
                          field = field.substring(1);
                          select = 0;
                          break;
                      case '+':
                          field = field.substring(1);
                          break;
                  }
                  result.fields[field] = select;
              }
          });
      }
      var sort = req.anyParam('sort');
      if (sort) {
          result.options.sort = {};
          sort.split(',').forEach(function (field) {
              field = field.trim();
              if (field) {
                  var order = 1;
                  switch (field.charAt(0)) {
                      case '-':
                          field = field.substring(1);
                          order = -1;
                          break;
                      case '+':
                          field = field.substring(1);
                          break;
                  }
                  result.options.sort[field] = order;
              }
          });
          result.params.sort = sort;
      }
      var skip = req.anyParam('skip') || req.anyParam('offset');
      if (skip) {
          result.options.skip = parseInt(skip, 10);
          result.params.skip = skip;
      }
      var limit = req.anyParam('limit');
      if (limit) {
          result.options.limit = parseInt(limit, 10);
          result.params.limit = limit;
      }
      return result;
  }