lib/impl/getSubmissions/index.js
function paginateList(formSubmissionModel, params, callback) {
  logger.debug("paginateList", params);
  var query = params.query || {};
  var paginate = params.paginate || {};
  var fieldModel = params.fieldModel;

  //Sorting can be defined by the user
  var sortBy = params.sortBy || {
    submissionCompletedTimestamp: -1
  };

  formSubmissionModel.paginate(query, {
    page: paginate.page,
    limit: paginate.limit,
    select: CONSTANTS.SUBMISSION_SUMMARY_FIELD_SELECTION,
    populate: {"path": "formFields.fieldId", "model": fieldModel, "select": "_id type name"},
    sortBy: sortBy,
    lean: true
  }, function(err, submissionsResult) {

    //Returning pagination metadata. Useful for displaying tables etc.
    var paginationResult = _.extend({
      pages: submissionsResult.pages,
      total: submissionsResult.total
    }, params);

    handleListResult(err, paginationResult, submissionsResult.docs, callback);
  });
}
function paginateList(formSubmissionModel, params, callback) {
  logger.debug("paginateList", params);
  var query = params.query || {};
  var paginate = params.paginate || {};
  var fieldModel = params.fieldModel;

  //Sorting can be defined by the user
  var sortBy = params.sortBy || {
    submissionCompletedTimestamp: -1
  };

  formSubmissionModel.paginate(query, {
    page: paginate.page,
    limit: paginate.limit,
    select: CONSTANTS.SUBMISSION_SUMMARY_FIELD_SELECTION,
    populate: {"path": "formFields.fieldId", "model": fieldModel, "select": "_id type name"},
    sortBy: sortBy,
    lean: true
  }, function(err, submissionsResult) {

    //Returning pagination metadata. Useful for displaying tables etc.
    var paginationResult = _.extend({
      pages: submissionsResult.pages,
      total: submissionsResult.total
    }, params);

    handleListResult(err, paginationResult, submissionsResult.docs, callback);
  });
}
function paginateList ( formSubmissionModel , params , callback ) { logger . debug ( "paginateList" , params ) ; var query = params . query || { } ; var paginate = params . paginate || { } ; var fieldModel = params . fieldModel ; //Sorting can be defined by the user var sortBy = params . sortBy || { submissionCompletedTimestamp : - 1 } ; formSubmissionModel . paginate ( query , { page : paginate . page , limit : paginate . limit , select : CONSTANTS . SUBMISSION_SUMMARY_FIELD_SELECTION , populate : { "path" : "formFields.fieldId" , "model" : fieldModel , "select" : "_id type name" } , sortBy : sortBy , lean : true } , function ( err , submissionsResult ) { //Returning pagination metadata. Useful for displaying tables etc. var paginationResult = _ . extend ( { pages : submissionsResult . pages , total : submissionsResult . total } , params ) ; handleListResult ( err , paginationResult , submissionsResult . docs , callback ) ; } ) ; }
paginateList - Returning a paginated list of submissions.

@param  {object} formSubmissionModel Submission Mongoose Model
@param  {object} params
@param  {object} params.query          Query to filter by.
@param  {object} params.paginate       Pagination parameters
@param  {number} params.paginate.page  Pagination page
@param  {number} params.paginate.limit Page to return
@param  {number} params.paginate.filter String to filter submissions by
@param  {function} callback
paginateList - Returning a paginated list of submissions .