Refactoring database and model definition into its own file
This commit is contained in:
1 parent
555ae80afc
commit
b64126a7fe
3 files changed
+27
-63
No files matched your search
@@ -0,0 +1,20 @@
|
||||
const Sequelize = require('sequelize');
|
||||
const Op = Sequelize.Op
|
||||
|
||||
// Setup database, using credentials set in .env
|
||||
const sequelize = new Sequelize('database', process.env.DB_USER, process.env.DB_PASS, {
|
||||
dialect: 'sqlite',
|
||||
storage: '.data/database.sqlite'
|
||||
});
|
||||
|
||||
// Define 'readings' table structure
|
||||
const Readings = sequelize.define('readings', {
|
||||
timestamp: {
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
reading: {
|
||||
type: Sequelize.INTEGER
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {Op, Readings}
|
||||
Reference in new issue
Block a user