function doFindAndCountAll(reqResNext, props, opts, resultObj) {
  return u.getScopedModel(props, opts.attributes)
    .findAndCountAll(opts)
    .then((o) => {
      resultObj.dbTime = new Date() - resultObj.reqStartTime;
      reqResNext.res.set(COUNT_HEADER_NAME, o.count);
      return o.rows.map((row) => {
        if (props.modelName === 'Lens') {
          delete row.dataValues.library;
        }

        return u.responsify(row, props, reqResNext.req.method);
      });
    })
    .catch((err) => u.handleError(reqResNext.next, err, props.modelName));
} // doFindAndCountAll
/**
 * Finds all matching records but only returns a subset of the results for
 * pagination. Includes a header with the full count.
 *
 * NOTE : Sequelize is not able to generate the right postgres sql aggeragate
 * query for Subject and Aspect objects to count the samples associated with
 * them. So, these models are scoped before finding them and the length
 * of the associated sample array is used as the sample count.
 *
 * @param {Object} reqResNext - The object containing the request object, the
 *  response object and the next middleware function in the stack
 * @param {Object} props - The helpers/nouns module for the given DB model
 * @param {Object} opts - The "options" object to pass into the Sequelize
 *  find command
 */
Finds all matching records but only returns a subset of the results for
pagination. Includes a header with the full count.

NOTE : Sequelize is not able to generate the right postgres sql aggeragate
query for Subject and Aspect objects to count the samples associated with
them. So, these models are scoped before finding them and the length
of the associated sample array is used as the sample count.

@param {Object} reqResNext - The object containing the request object, the
response object and the next middleware function in the stack
@param {Object} props - The helpers/nouns module for the given DB model
@param {Object} opts - The "options" object to pass into the Sequelize
find command
Finds all matching records but only returns a subset of the results for pagination . Includes a header with the full count . NOTE : Sequelize is not able to generate the right postgres sql aggeragate query for Subject and Aspect objects to count the samples associated with them . So these models are scoped before finding them and the length of the associated sample array is used as the sample count . @param { Object } reqResNext - The object containing the request object the response object and the next middleware function in the stack @param { Object } props - The helpers / nouns module for the given DB model @param { Object } opts - The " options " object to pass into the Sequelize find command
function doFindAndCountAll(reqResNext, props, opts, resultObj) {
  return u.getScopedModel(props, opts.attributes)
    .findAndCountAll(opts)
    .then((o) => {
      resultObj.dbTime = new Date() - resultObj.reqStartTime;
      reqResNext.res.set(COUNT_HEADER_NAME, o.count);
      return o.rows.map((row) => {
        if (props.modelName === 'Lens') {
          delete row.dataValues.library;
        }
        return u.responsify(row, props, reqResNext.req.method);
      });
    })
    .catch((err) => u.handleError(reqResNext.next, err, props.modelName));
} 
function doFindAndCountAll ( reqResNext , props , opts , resultObj ) { return u . getScopedModel ( props , opts . attributes ) . findAndCountAll ( opts ) . then ( ( o ) => { resultObj . dbTime = new Date ( ) - resultObj . reqStartTime ; reqResNext . res . set ( COUNT_HEADER_NAME , o . count ) ; return o . rows . map ( ( row ) => { if ( props . modelName === 'Lens' ) { delete row . dataValues . library ; } return u . responsify ( row , props , reqResNext . req . method ) ; } ) ; } ) . catch ( ( err ) => u . handleError ( reqResNext . next , err , props . modelName ) ) ; }
Finds all matching records but only returns a subset of the results for
 pagination.
Finds all matching records but only returns a subset of the results for pagination .
// doFindAndCountAll