Adding sync() commands to database scripts

This commit is contained in:
JayWll 2020-04-13 10:01:40 -06:00
parent 8832c658bf
commit 6d3e74aac9
2 changed files with 12 additions and 7 deletions

View File

@ -19,6 +19,9 @@ request({
console.log(response.body.length + ' items retrieved')
// Sync the database table
await db.Settings.sync()
// Remove existing database items
await db.Readings.destroy({truncate: true})

View File

@ -2,11 +2,13 @@ const db = require('../db/db')
const path = require('path')
require('dotenv').config({path: path.join(__dirname, '../../.env')})
// Remove all previous settings
db.Settings.destroy({truncate: true})
db.Settings.sync().then(() => {
// Remove all previous settings
db.Settings.destroy({truncate: true})
// Create settings
db.Settings.create({ key: 'low-trigger', value: 100 })
db.Settings.create({ key: 'high-trigger', value: 900 })
db.Settings.create({ key: 'low', value: false })
db.Settings.create({ key: 'alert', value: false })
// Create settings
db.Settings.create({ key: 'low-trigger', value: 100 })
db.Settings.create({ key: 'high-trigger', value: 900 })
db.Settings.create({ key: 'low', value: false })
db.Settings.create({ key: 'alert', value: false })
})