Last active
August 30, 2016 22:32
-
-
Save johncmckim/3fb6274f39ce1080fcfd6d972d874f59 to your computer and use it in GitHub Desktop.
Garden Aid - Web BFF - DynamoDB Tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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