DynamoDBHelper.prototype.createTable = function()

in source/shared-modules/dynamodb-helper/dynamodb-helper.js [174:201]


DynamoDBHelper.prototype.createTable = function(dynamodb, callback) {
   var newTable = {
       TableName: this.tableDefinition.TableName,
   };
   dynamodb.describeTable(newTable, function (error, data) {
       if (!error) {
           callback(null);
       } else {
           winston.debug("Table " + newTable.TableName + " does not exist. DescribeTable error: " + error);
           dynamodb.createTable(this.tableDefinition, function (err, data) {
               if (err) {
                   winston.error("Unable to create table: " + this.tableDefinition.TableName);
                   callback(err);
               } else {
                   var tableName = {TableName: this.tableDefinition.TableName};
                   dynamodb.waitFor('tableExists', tableName, function (err, data) {
                       if (err) {
                           callback(err);
                       } else {
                           winston.debug("Created table. Table description JSON:", JSON.stringify(data, null, 2));
                           callback(null);
                       }
                   });
               }
           }.bind(this));
       }
   }.bind(this));
}