clarkie / dynogels

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

Add on Demand mode #183

Open aneilbaboo opened 5 years ago

aneilbaboo commented 5 years ago

This adds a new schema attribute, billingMode, which can be set to 'PROVISIONED' (the default) or 'PAY_PER_REQUEST', which causes the table to run in On Demand mode. This value can also be provided on a per-table basis to the dynogels.createTables` function.

const Account = dynogels.define('Account', {
  hashKey : 'id',
  schema : {
    id : Joi.string()
  },
  billingMode: 'PAY_PER_REQUEST'
});
dynogels.createTables({
  'Account': {
    billingMode: 'PAY_PER_REQUEST'
  }
}, function(err) {
  if (err) {
    console.log('Error creating tables: ', err);
  } else {
    console.log('Tables has been created');
  }
});

Fixes #182

aneilbaboo commented 4 years ago

Rebased on current master and addressed the comment from @rchl.