UNPKG

dbl-coins-invest

Version:

Sharade DBL package over other coins invest services

84 lines (75 loc) 1.97 kB
'use strict'; var dynamoose = require('dynamoose'); if (!!process.env.LOCAL) { dynamoose.local(); } else { dynamoose.AWS.config.credentials = new dynamoose.AWS.SharedIniFileCredentials({ profile: 'coinsProfile' }); } dynamoose.AWS.config.update({ region: 'us-east-1' }); var Schema = dynamoose.Schema; var configSchema = new Schema({ id: { type: String, rangeKey: true }, userSub: { type: String, validate: function validate(v) { return v.length > 0; }, required: true, hashKey: true }, userData: { firstName: String, lastName: String, email: String }, type: { // absPrice / pctPrice / absMCup / pctMCup type: String, index: { global: true, rangeKey: 'userSub', name: 'TypeIndex', project: true, // ProjectionType: ALL throughput: 5 // read and write are both 5 } }, isActive: { type: Boolean }, config: { type: Object, get: function get(val) { try { return JSON.parse(val); } catch (err) { return val; } } }, idleInterval: { type: Number // interval in mlseconds between lastNotified }, lastNotified: { type: Number }, notificationStatus: { type: String // status of notification failed.... error... success... } }, { throughput: { read: 5, write: 5 } }); var schemaOptions = { update: true, waitForActive: true, waitForActiveTimeout: 180000 }; var tableName = void 0; if (!!process.env.DYNAMO_ALERT_TABLE) tableName = process.env.DYNAMO_ALERT_TABLE;else throw new Error('No table name provided (DYNAMO_ALERT_TABLE)'); var NotificationModel = dynamoose.model(tableName, configSchema, schemaOptions); module.exports = { NotificationModel: NotificationModel };