clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Other
490 stars 110 forks source link

Ability to call "createTables" without doing "describeTable" #30

Closed FLavalliere closed 7 years ago

FLavalliere commented 8 years ago

This could speed-up the environment in the event large of amount of table are being used. With a specific flag, it would assume that the table are already existing and in the right format.

FLavalliere commented 8 years ago

One way I've done it currently is to comment the following line:

      callback(null);
/*      model.updateTable(err => {
        if (err) {
          model.log.warn({ err: err }, 'failed to update table %s: %s', tableName, err);
          return callback(err);
        }

        model.log.info('waiting for table: %s to become ACTIVE', tableName);
        internals.waitTillActive(model, callback);
      });
*/

Just for testing.

clarkie commented 7 years ago

I'm a little confused why you'd need to call createTables if you know the tables exist. I have an application config setting that allows us to trigger table creation based off a flag or environment variable:

function maybeCreateTables(config, callback) {
  if (config.createTables) {
    console.log('CREATING TABLES...'); // eslint-disable-line
    return dynogels.createTables(callback);
  }
  return callback();
}

If I've misunderstood the question then please let me know. Thanks

FLavalliere commented 7 years ago

Hmm, i see... I though to use the "models" we had to wrap the object inside the createTables(callback);

clarkie commented 7 years ago

The models need to have been initialised by calling define method. As long as that is called before you use it then there shouldn't be a problem.