src/seeder.js
function writeSeeds(dynamodbWriteFunction, tableName, seeds) {
  if (!dynamodbWriteFunction) {
    throw new Error("dynamodbWriteFunction argument must be provided");
  }
  if (!tableName) {
    throw new Error("table name argument must be provided");
  }
  if (!seeds) {
    throw new Error("seeds argument must be provided");
  }

  if (seeds.length > 0) {
    const seedChunks = _.chunk(seeds, MAX_MIGRATION_CHUNK);
    return BbPromise.map(
      seedChunks,
      (chunk) => writeSeedBatch(dynamodbWriteFunction, tableName, chunk),
      { concurrency: MIGRATION_SEED_CONCURRENCY }
    )
      .then(() => console.log("Seed running complete for table: " + tableName));
  }
}
function writeSeeds(dynamodbWriteFunction, tableName, seeds) {
  if (!dynamodbWriteFunction) {
    throw new Error("dynamodbWriteFunction argument must be provided");
  }
  if (!tableName) {
    throw new Error("table name argument must be provided");
  }
  if (!seeds) {
    throw new Error("seeds argument must be provided");
  }

  if (seeds.length > 0) {
    const seedChunks = _.chunk(seeds, MAX_MIGRATION_CHUNK);
    return BbPromise.map(
      seedChunks,
      (chunk) => writeSeedBatch(dynamodbWriteFunction, tableName, chunk),
      { concurrency: MIGRATION_SEED_CONCURRENCY }
    )
      .then(() => console.log("Seed running complete for table: " + tableName));
  }
}
function writeSeeds ( dynamodbWriteFunction , tableName , seeds ) { if ( ! dynamodbWriteFunction ) { throw new Error ( "dynamodbWriteFunction argument must be provided" ) ; } if ( ! tableName ) { throw new Error ( "table name argument must be provided" ) ; } if ( ! seeds ) { throw new Error ( "seeds argument must be provided" ) ; } if ( seeds . length > 0 ) { const seedChunks = _ . chunk ( seeds , MAX_MIGRATION_CHUNK ) ; return BbPromise . map ( seedChunks , ( chunk ) => writeSeedBatch ( dynamodbWriteFunction , tableName , chunk ) , { concurrency : MIGRATION_SEED_CONCURRENCY } ) . then ( ( ) => console . log ( "Seed running complete for table: " + tableName ) ) ; } }
Writes a seed corpus to the given database table
@param {function} dynamodbWriteFunction The DynamoDB DocumentClient.batchWrite or DynamoDB.batchWriteItem function
@param {string} tableName The table name
@param {any[]} seeds The seed values
Writes a seed corpus to the given database table