From 69afaecaa402c4b3909955ccab416fbef48deafb Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Fri, 10 May 2024 09:27:06 +0100 Subject: [PATCH] minor backend changes --- backend/db/database.js | 8 +++++++- backend/db/sequelizeHooks.js | 3 +-- backend/server.js | 3 ++- main.js | 6 +++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/db/database.js b/backend/db/database.js index 50551f6..ff7e7df 100644 --- a/backend/db/database.js +++ b/backend/db/database.js @@ -1,8 +1,14 @@ const { Sequelize } = require('sequelize'); +const fs = require('fs'); + +const logStream = fs.createWriteStream('sequelize.log', { flags: 'a' }); const sequelize = new Sequelize('Showzy', 'root', 'password', { host: 'localhost', - dialect: 'mysql' + dialect: 'mysql', + logging: (msg) => { + logStream.write(msg + '\n'); + } }); module.exports = sequelize; \ No newline at end of file diff --git a/backend/db/sequelizeHooks.js b/backend/db/sequelizeHooks.js index ee6b373..4bfb6a4 100644 --- a/backend/db/sequelizeHooks.js +++ b/backend/db/sequelizeHooks.js @@ -40,7 +40,6 @@ UserCollectionEntry.afterCreate(async (instance, options) => { // * entry update (order) UserCollectionEntry.afterUpdate(async (instance, options) => { - console.log("we're in after update!!!!!") try { // ? mimicking a change in UserCollection to trigger updatedAt property update for the UserCollection const userCollections = await UserCollection.findByPk(instance.user_collection_id); @@ -129,7 +128,7 @@ EntrySeen.afterCreate(async (instance, options) => { // this will ensure that the entry is updated anyways to trigger the updatedAt property let update = { - title: sequelize.literal('title') + watchlist: false }; // ? comparing the instance.date_seen with the entry date_first_seen & diff --git a/backend/server.js b/backend/server.js index 7a552e2..e1ba0c9 100644 --- a/backend/server.js +++ b/backend/server.js @@ -55,12 +55,13 @@ app.use('/api/v1', routes); const relations = require('./db/relations.js'); const sequelizeHooks = require('./db/sequelizeHooks.js'); const { initializeGenres, initializeData } = require('./db/dataInitializer.js'); - +console.log(`Syning database schema...`); sequelize // .sync({force: true}) // will drop all tables and recreate them. // .sync({ alter: true }) // will attempt to automatically alter tables to fit the model definitions. .sync() .then((result) => { + console.log(`Database schema synced...`); initializeData(); app.listen(PORT, () => { diff --git a/main.js b/main.js index c88d30d..d3b3864 100644 --- a/main.js +++ b/main.js @@ -7,8 +7,8 @@ let win; function createWindow() { win = new BrowserWindow({ - width: 800, - height: 600, + width: 1200, + height: 720, webPreferences: { nodeIntegration: true } @@ -32,7 +32,7 @@ function createWindow() { app.on('ready', () => { // Start the Express server - const expressProcess = spawn('node', ['show-z/backend/server.js']); + const expressProcess = spawn('node', ['backend/server.js']); expressProcess.stdout.on('data', (data) => { console.log(`Express stdout: ${data}`); });