src/seeder.js
function writeSeedBatch(dynamodbWriteFunction, tableName, seeds) {
  const params = {
    RequestItems: {
      [tableName]: seeds.map((seed) => ({
        PutRequest: {
          Item: seed,
        },
      })),
    },
  };
  return new BbPromise((resolve, reject) => {
    // interval lets us know how much time we have burnt so far. This lets us have a backoff mechanism to try
    // again a few times in case the Database resources are in the middle of provisioning.
    let interval = 0;
    function execute(interval) {
      setTimeout(() => dynamodbWriteFunction(params, (err) => {
        if (err) {
          if (err.code === "ResourceNotFoundException" && interval <= 5000) {
            execute(interval + 1000);
          } else {
            reject(err);
          }
        } else {
          resolve();
        }
      }), interval);
    }
    execute(interval);
  });
}
function writeSeedBatch(dynamodbWriteFunction, tableName, seeds) {
  const params = {
    RequestItems: {
      [tableName]: seeds.map((seed) => ({
        PutRequest: {
          Item: seed,
        },
      })),
    },
  };
  return new BbPromise((resolve, reject) => {
    // interval lets us know how much time we have burnt so far. This lets us have a backoff mechanism to try
    // again a few times in case the Database resources are in the middle of provisioning.
    let interval = 0;
    function execute(interval) {
      setTimeout(() => dynamodbWriteFunction(params, (err) => {
        if (err) {
          if (err.code === "ResourceNotFoundException" && interval <= 5000) {
            execute(interval + 1000);
          } else {
            reject(err);
          }
        } else {
          resolve();
        }
      }), interval);
    }
    execute(interval);
  });
}
function writeSeedBatch ( dynamodbWriteFunction , tableName , seeds ) { const params = { RequestItems : { [ tableName ] : seeds . map ( ( seed ) => ( { PutRequest : { Item : seed , } , } ) ) , } , } ; return new BbPromise ( ( resolve , reject ) => { // interval lets us know how much time we have burnt so far. This lets us have a backoff mechanism to try // again a few times in case the Database resources are in the middle of provisioning. let interval = 0 ; function execute ( interval ) { setTimeout ( ( ) => dynamodbWriteFunction ( params , ( err ) => { if ( err ) { if ( err . code === "ResourceNotFoundException" && interval <= 5000 ) { execute ( interval + 1000 ) ; } else { reject ( err ) ; } } else { resolve ( ) ; } } ) , interval ) ; } execute ( interval ) ; } ) ; }
Writes a batch chunk of migration seeds to DynamoDB. DynamoDB has a limit on the number of
items that may be written in a batch operation.
@param {function} dynamodbWriteFunction The DynamoDB DocumentClient.batchWrite or DynamoDB.batchWriteItem function
@param {string} tableName The table name being written to
@param {any[]} seeds The migration seeds being written to the table
Writes a batch chunk of migration seeds to DynamoDB . DynamoDB has a limit on the number of items that may be written in a batch operation .