Skip to content

Instantly share code, notes, and snippets.

@johncmckim
Last active August 30, 2016 22:32
Show Gist options
  • Save johncmckim/3fb6274f39ce1080fcfd6d972d874f59 to your computer and use it in GitHub Desktop.
Save johncmckim/3fb6274f39ce1080fcfd6d972d874f59 to your computer and use it in GitHub Desktop.
Garden Aid - Web BFF - DynamoDB Tables
const vogels = require('vogels-promisified');
const Joi = require('joi');
module.exports = () => {
const moistureTableName = process.env.moistureTableName;
if(!moistureTableName) {
throw new Error("Missing moisture table name");
}
const Moisture = vogels.define('Moisture', {
hashKey: 'ClientId',
rangeKey: 'Timestamp',
schema: {
ClientId: Joi.string(),
Timestamp: Joi.date(),
Data: Joi.object().keys({
DeviceId: Joi.string(),
Level: Joi.number(),
Recorded: Joi.date(),
}),
},
tableName: moistureTableName
});
return {
Moisture: Moisture
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment