From 7e8bb07ca93555968c2b51de55ea702ec27f4d7c Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 27 Jun 2017 16:25:35 -0700 Subject: [PATCH] updated table name --- helpers/libraries/analytics.js | 7 ++++++- models/{usage.js => analytics.js} | 6 +++--- server.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) rename models/{usage.js => analytics.js} (84%) diff --git a/helpers/libraries/analytics.js b/helpers/libraries/analytics.js index 62296765..509d7362 100644 --- a/helpers/libraries/analytics.js +++ b/helpers/libraries/analytics.js @@ -1,11 +1,16 @@ const db = require('../../models'); +const logger = require('winston'); function createAnalyticsRecord (action, url, ipAddress, result) { - db.Usage.create({ + db.Analytics.create({ action, url, ipAddress, result, + }) + .then() + .catch(error => { + logger.error('sequelize error', error); }); }; diff --git a/models/usage.js b/models/analytics.js similarity index 84% rename from models/usage.js rename to models/analytics.js index 5c161597..fca25233 100644 --- a/models/usage.js +++ b/models/analytics.js @@ -1,6 +1,6 @@ module.exports = (sequelize, { STRING }) => { - const Usage = sequelize.define( - 'Usage', + const Analytics = sequelize.define( + 'Analytics', { action: { type : STRING, @@ -23,5 +23,5 @@ module.exports = (sequelize, { STRING }) => { freezeTableName: true, } ); - return Usage; + return Analytics; }; diff --git a/server.js b/server.js index 8df35748..743e5fd7 100644 --- a/server.js +++ b/server.js @@ -67,7 +67,7 @@ const http = require('./routes/sockets-routes.js')(app, siofu, hostedContentPath // sync sequelize // wrap the server in socket.io to intercept incoming sockets requests // start server -db.sequelize.sync({}).then(() => { +db.sequelize.sync().then(() => { http.listen(PORT, () => { winston.info(`Server is listening on PORT ${PORT}`); });