minor backend changes
This commit is contained in:
1 parent
1bda64003c
commit
69afaecaa4
4 files changed
+13
-7
No files matched your search
@@ -1,8 +1,14 @@
|
|||||||
const { Sequelize } = require('sequelize');
|
const { Sequelize } = require('sequelize');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const logStream = fs.createWriteStream('sequelize.log', { flags: 'a' });
|
||||||
|
|
||||||
const sequelize = new Sequelize('Showzy', 'root', 'password', {
|
const sequelize = new Sequelize('Showzy', 'root', 'password', {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
dialect: 'mysql'
|
dialect: 'mysql',
|
||||||
|
logging: (msg) => {
|
||||||
|
logStream.write(msg + '\n');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = sequelize;
|
module.exports = sequelize;
|
||||||
@@ -40,7 +40,6 @@ UserCollectionEntry.afterCreate(async (instance, options) => {
|
|||||||
|
|
||||||
// * entry update (order)
|
// * entry update (order)
|
||||||
UserCollectionEntry.afterUpdate(async (instance, options) => {
|
UserCollectionEntry.afterUpdate(async (instance, options) => {
|
||||||
console.log("we're in after update!!!!!")
|
|
||||||
try {
|
try {
|
||||||
// ? mimicking a change in UserCollection to trigger updatedAt property update for the UserCollection
|
// ? mimicking a change in UserCollection to trigger updatedAt property update for the UserCollection
|
||||||
const userCollections = await UserCollection.findByPk(instance.user_collection_id);
|
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
|
// this will ensure that the entry is updated anyways to trigger the updatedAt property
|
||||||
let update = {
|
let update = {
|
||||||
title: sequelize.literal('title')
|
watchlist: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// ? comparing the instance.date_seen with the entry date_first_seen &
|
// ? comparing the instance.date_seen with the entry date_first_seen &
|
||||||
|
|||||||
+2
-1
@@ -55,12 +55,13 @@ app.use('/api/v1', routes);
|
|||||||
const relations = require('./db/relations.js');
|
const relations = require('./db/relations.js');
|
||||||
const sequelizeHooks = require('./db/sequelizeHooks.js');
|
const sequelizeHooks = require('./db/sequelizeHooks.js');
|
||||||
const { initializeGenres, initializeData } = require('./db/dataInitializer.js');
|
const { initializeGenres, initializeData } = require('./db/dataInitializer.js');
|
||||||
|
console.log(`Syning database schema...`);
|
||||||
sequelize
|
sequelize
|
||||||
// .sync({force: true}) // will drop all tables and recreate them.
|
// .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({ alter: true }) // will attempt to automatically alter tables to fit the model definitions.
|
||||||
.sync()
|
.sync()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
console.log(`Database schema synced...`);
|
||||||
initializeData();
|
initializeData();
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ let win;
|
|||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 800,
|
width: 1200,
|
||||||
height: 600,
|
height: 720,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ function createWindow() {
|
|||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
// Start the Express server
|
// 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) => {
|
expressProcess.stdout.on('data', (data) => {
|
||||||
console.log(`Express stdout: ${data}`);
|
console.log(`Express stdout: ${data}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user