function doFindResponse(reqResNext, props, opts, resultObj) {
  if (opts.limit || opts.offset) {
    reqResNext.res.links({
      prev: reqResNext.req.originalUrl,
      next: fu.getNextUrl(reqResNext.req.originalUrl, opts.limit, opts.offset),
    });
  }

  return doFindAndCountAll(reqResNext, props, opts, resultObj)
    .then((retVal) => {
      u.sortArrayObjectsByField(props, retVal);

      // loop through remove values to delete property
      if (props.fieldsToExclude) {
        for (let i = retVal.length - 1; i >= 0; i--) {
          u.removeFieldsFromResponse(props.fieldsToExclude, retVal[i]);
        }
      }

      if (props.cacheKey) {
        // cache the object by cacheKey.
        const strObj = JSON.stringify(retVal);
        redisCache.setex(props.cacheKey, props.cacheExpiry, strObj);
      }

      u.logAPI(reqResNext.req, resultObj, retVal);
      reqResNext.res.status(httpStatus.OK).json(retVal);
    })
    .catch((err) => u.handleError(reqResNext.next, err, props.modelName));
}
/**
 * Finds all matching records. This function is just a wrapper around
 * doFindAll or doFindAndCountAll, depending upon whether we need to paginate
 * the results. If cacheKey is provided, we cache the response.
 *
 * @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. This function is just a wrapper around
doFindAll or doFindAndCountAll, depending upon whether we need to paginate
the results. If cacheKey is provided, we cache the response.

@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 . This function is just a wrapper around doFindAll or doFindAndCountAll depending upon whether we need to paginate the results . If cacheKey is provided we cache the response . @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 doFindResponse(reqResNext, props, opts, resultObj) {
  if (opts.limit || opts.offset) {
    reqResNext.res.links({
      prev: reqResNext.req.originalUrl,
      next: fu.getNextUrl(reqResNext.req.originalUrl, opts.limit, opts.offset),
    });
  }
  return doFindAndCountAll(reqResNext, props, opts, resultObj)
    .then((retVal) => {
      u.sortArrayObjectsByField(props, retVal);
      if (props.fieldsToExclude) {
        for (let i = retVal.length - 1; i >= 0; i--) {
          u.removeFieldsFromResponse(props.fieldsToExclude, retVal[i]);
        }
      }
      if (props.cacheKey) {
        const strObj = JSON.stringify(retVal);
        redisCache.setex(props.cacheKey, props.cacheExpiry, strObj);
      }
      u.logAPI(reqResNext.req, resultObj, retVal);
      reqResNext.res.status(httpStatus.OK).json(retVal);
    })
    .catch((err) => u.handleError(reqResNext.next, err, props.modelName));
}
function doFindResponse ( reqResNext , props , opts , resultObj ) { if ( opts . limit || opts . offset ) { reqResNext . res . links ( { prev : reqResNext . req . originalUrl , next : fu . getNextUrl ( reqResNext . req . originalUrl , opts . limit , opts . offset ) , } ) ; } return doFindAndCountAll ( reqResNext , props , opts , resultObj ) . then ( ( retVal ) => { u . sortArrayObjectsByField ( props , retVal ) ; if ( props . fieldsToExclude ) { for ( let i = retVal . length - 1 ; i >= 0 ; i -- ) { u . removeFieldsFromResponse ( props . fieldsToExclude , retVal [ i ] ) ; } } if ( props . cacheKey ) { const strObj = JSON . stringify ( retVal ) ; redisCache . setex ( props . cacheKey , props . cacheExpiry , strObj ) ; } u . logAPI ( reqResNext . req , resultObj , retVal ) ; reqResNext . res . status ( httpStatus . OK ) . json ( retVal ) ; } ) . catch ( ( err ) => u . handleError ( reqResNext . next , err , props . modelName ) ) ; }
Finds all matching records.
Finds all matching records .
// loop through remove values to delete property // cache the object by cacheKey.