Paginate list from database.
@param {Object} req Request
@param {Object} res Response
776314
function (req, res) {
    var options = {
      operation: 'PAGINATE',
      res: res,
    };
    exports.paginate.before(req, res, options);
    vulpejs.models.paginate({
      model: req.params.model,
      query: req.params.query || {},
      populate: req.params.populate || '',
      sort: req.params.sort || {},
      page: req.params.page || 1,
      userId: req.session['user-id'],
      callback: {
        success: function (data) {
          exports.paginate.after(req, res, data);
          res.json({
            items: data.items,
            pageCount: data.pageCount,
            itemCount: data.itemCount,
          });
        },
        error: function (error) {
          exports.response.error(options, error);
        },
      },
    });
  }
889053
function list(req, res, next) {
  forms.getAllAppForms(req.connectionOptions, formsResultHandlers(constants.resultTypes.formProjects, req, next));
}
864530
def list(self, request, *args, **kwargs):
        

        queryset = self.get_filtered_queryset(get_request_data(request))
        # Switch between paginated or standard style responses
        page = self.paginate_queryset(queryset)
        if page is not None:
            serializer = self.get_serializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = self.get_serializer(queryset, many=True)
        return Response(serializer.data)
868412
def process_resource(self, req, resp, resource):
        

        try:
            model = resource.model

            req.fields = fields.init(req, model)
            req.filters = filters.init(req, model)
            req.includes = includes.init(req, model)
            req.pages = pages.init(req, model)
            req.sorts = sorts.init(req, model)
        except AttributeError:
            pass
        except InvalidQueryParams as exc:
            abort(exc)
82856
function (res, args) {
            // callback args preparation
            var requestObject = args.requestObject, actionQueuing = args.actionQueuing;
            var id = args.id, senderObject = args.senderObject;
            // var cb = args.cb, session = args.session, requestHandler = args.requestHandler

            // starts right now for next item in action queuing
            if (actionQueuing) {
                actionQueuing.handleNextRequest(id);
            }

            // updated resources
            var newRes = {
                requestUrl : res.url,
                requestObject : requestObject,
                responseXML : res.responseXML,
                responseText : res.responseText,
                responseJSON : res.responseJSON,
                status : res.status, // http status (e.g.: 404)
                error : res.error, // contains error message

                // Should we stop supporting the following properties ?
                // These properties can be set by IO filters (through the sender object) to bypass the response handler
                data : senderObject.responseData,
                errorData : senderObject.responseErrorData
            };

            args.res = newRes;

            this._processOnResponse(args);
        }
205970
def list(self, request):
        

        max_items_per_page = getattr(self, 'max_per_page',
                                      getattr(settings, 'AJAX_MAX_PER_PAGE', 100))
        requested_items_per_page = request.POST.get("items_per_page", 20)
        items_per_page = min(max_items_per_page, requested_items_per_page)
        current_page = request.POST.get("current_page", 1)

        if not self.can_list(request.user):
            raise AJAXError(403, _("Access to this endpoint is forbidden"))

        objects = self.get_queryset(request)

        paginator = Paginator(objects, items_per_page)

        try:
            page = paginator.page(current_page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            page = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), return empty list.
            page = EmptyPageResult()

        data = [encoder.encode(record) for record in page.object_list]
        return EnvelopedResponse(data=data, metadata={'total': paginator.count})
1249777
function list(params, cb) {
  var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions", params);
  var method = "GET";
  var data = {};

  params.resourcePath = resourcePath;
  params.method = method;
  params.data = data;

  mbaasRequest.admin(params, cb);
}
1369796
function list ({ limit, page }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify('data', 'total')

      Joi.validate({ limit, page }, validationRules.list, (err) => {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          WITH total AS (
            SELECT COUNT(*) AS cnt FROM organizations
          )
          SELECT o.*, t.cnt::INTEGER AS total
          FROM organizations AS o
          INNER JOIN total AS t ON 1=1
          ORDER BY UPPER(o.name)
        `

        if (limit) {
          sqlQuery.append(SQL` LIMIT ${limit}`)
        }
        if (limit && page) {
          let offset = (page - 1) * limit
          sqlQuery.append(SQL` OFFSET ${offset}`)
        }
        db.query(sqlQuery, function (err, result) {
          if (err) return cb(Boom.badImplementation(err))
          let total = result.rows.length > 0 ? result.rows[0].total : 0
          return cb(null, result.rows.map(mapping.organization), total)
        })
      })

      return promise
    }
740422
def paginate_announcements_list(request, context, items):
    

    # pagination
    if "start" in request.GET:
        try:
            start_num = int(request.GET.get("start"))
        except ValueError:
            start_num = 0
    else:
        start_num = 0

    display_num = 10
    end_num = start_num + display_num
    prev_page = start_num - display_num
    more_items = ((len(items) - start_num) > display_num)
    try:
        items_sorted = items[start_num:end_num]
    except (ValueError, AssertionError):
        items_sorted = items[:display_num]
    else:
        items = items_sorted

    context.update({
        "items": items,
        "start_num": start_num,
        "end_num": end_num,
        "prev_page": prev_page,
        "more_items": more_items,
    })

    return context, items
1188791
function count(req, res,next) {
  db.tags.count(function(err, count) {
    if(err) { return next(err); }
    res.json({count: count});
  });
}
1180863
function paginate(q, options, callback) {
  /*jshint validthis:true */
  var query, skipFrom, sort, columns, populate, lean, model = this;
  columns = options.columns || null;
  sort = options.sort || options.sortBy || null; // TODO: get rid of sortBy in major version
  populate = options.populate || null;
  var lean = options.lean || false;
  var pageNumber = options.page || 1;
  var resultsPerPage = options.limit || 10;
  skipFrom = (pageNumber * resultsPerPage) - resultsPerPage;
  query = model.find(q);
  if (columns !== null) {
    query = query.select(options.columns);
  }
  query = query.skip(skipFrom).limit(resultsPerPage);
  if (sort !== null) {
    query.sort(sort);
  }
  if (populate) {
    if (Array.isArray(populate)) {
      populate.forEach(function(field) {
        query = query.populate(field);
      });
    } else {
      query = query.populate(populate);
    }
  }
  if (lean) {
    query.lean();
  }

  if (typeof callback === 'function') {
    return handleCallback(query, q, model, resultsPerPage, callback);
  } else {
    return handlePromise(query, q, model, resultsPerPage);
  }
}
1223134
function present(req, res, next) {

    // Sort
    if (req._internal._sort) {
      req._internal._order = req._internal._order || 'ASC'
      req._internal.resource = _.sortBy(req._internal.resource, function (element) {
        return element[req._internal._sort]
      })
      if (req._internal._order === 'DESC') {
        req._internal.resource.reverse()
      }
    }

    // Slice result
    if (req._internal._end || req._internal._limit) {
      res.setHeader('X-Total-Count', req._internal.resource.length)
      res.setHeader('Access-Control-Expose-Headers', 'X-Total-Count')
    }
    req._internal._start = parseInt(req._internal._start) || 0
    if (req._internal._end) {
      req._internal.resource = req._internal.resource.slice(req._internal._start, parseInt(req._internal._end))
    } else if (req._internal._limit) {

      // Convert strings to int and sum to get end value
      req._internal.resource = req._internal.resource.slice(req._internal._start, parseInt(req._internal._start) + parseInt(req._internal._limit))
    }
    res.jsonp(req._internal.resource)
  }
369002
function list(req, res) {
  var s = '';
  this.state.connections.forEach(function(conn) {
    s += conn.toString();
  })
  res.send(null, s);
}
239034
def paginate_query(self, query):
        

        if self.paginator is None:
            return None

        return self.paginator.paginate_query(query, self.request)
777894
function serve(req, res) {
  var responseIsArray = Array.isArray(res.entityResponse);
  util.invariant(responseIsArray, 'Response values are required.');

  res.json({ values: res.entityResponse });
}
346454
function count(req, res) {
  var list = getList.call(this);
  return res.send(null, list.length);
}
636712
function(req, res, route) {
    req.on('data', function(data) {
      req.body = queryStringToJSON(data.toString());
      route.callback(req, res);
    });
  }