function checkCollectorsExist(seq, collectorNames) {
  if (!collectorNames || !collectorNames.length) {
    return [];
  }

  const options = {};
  options.where = whereClauseForNameInArr(collectorNames);

  // reject the request if collectorNames contain duplicate names
  return new Promise((resolve, reject) =>
    seq.models.Collector.findAll(options)
    .then((_collectors) => {
      /*
       * If requestBody does not have a collectors field, OR
       * if the number of collectors in requestBody MATCH the
       * GET result, order the collectors AND create the generator.
       * Else throw error since there are collectors that don't exist.
       */
      if (_collectors.length === collectorNames.length) {
        resolve(_collectors);
      }

      const err = new dbErrors.ResourceNotFoundError();
      err.resourceType = 'Collector';
      err.resourceKey = collectorNames;
      reject(err);
    })
  );
}
/**
 * If collectors exist, return a Promise with an
 * Array of collector objects referenced by collectorNames.
 * If collector names are not supplied, return a Promise
 * with an empty array
 * If collector names are invalid, reject with error.

 * @param {Object} seq The sequelize object
 * @param {Array} collectorNames Array of Strings
 * @returns {Promise} with an array if check passed, error otherwise
 */
If collectors exist, return a Promise with an
Array of collector objects referenced by collectorNames.
If collector names are not supplied, return a Promise
with an empty array
If collector names are invalid, reject with error.

@param {Object} seq The sequelize object
@param {Array} collectorNames Array of Strings
@returns {Promise} with an array if check passed, error otherwise
If collectors exist return a Promise with an Array of collector objects referenced by collectorNames . If collector names are not supplied return a Promise with an empty array If collector names are invalid reject with error . @param { Object } seq The sequelize object @param { Array } collectorNames Array of Strings @returns { Promise } with an array if check passed error otherwise
function checkCollectorsExist(seq, collectorNames) {
  if (!collectorNames || !collectorNames.length) {
    return [];
  }
  const options = {};
  options.where = whereClauseForNameInArr(collectorNames);
  return new Promise((resolve, reject) =>
    seq.models.Collector.findAll(options)
    .then((_collectors) => {
      if (_collectors.length === collectorNames.length) {
        resolve(_collectors);
      }
      const err = new dbErrors.ResourceNotFoundError();
      err.resourceType = 'Collector';
      err.resourceKey = collectorNames;
      reject(err);
    })
  );
}
function checkCollectorsExist ( seq , collectorNames ) { if ( ! collectorNames || ! collectorNames . length ) { return [ ] ; } const options = { } ; options . where = whereClauseForNameInArr ( collectorNames ) ; return new Promise ( ( resolve , reject ) => seq . models . Collector . findAll ( options ) . then ( ( _collectors ) => { if ( _collectors . length === collectorNames . length ) { resolve ( _collectors ) ; } const err = new dbErrors . ResourceNotFoundError ( ) ; err . resourceType = 'Collector' ; err . resourceKey = collectorNames ; reject ( err ) ; } ) ) ; }
If collectors exist, return a Promise with an
 Array of collector objects referenced by collectorNames.
If collectors exist return a Promise with an Array of collector objects referenced by collectorNames .
// reject the request if collectorNames contain duplicate names /*
       * If requestBody does not have a collectors field, OR
       * if the number of collectors in requestBody MATCH the
       * GET result, order the collectors AND create the generator.
       * Else throw error since there are collectors that don't exist.
       */