Created
September 26, 2018 11:12
-
-
Save SilencerWeb/5d0c121f779712ddc72dc46dea4aae43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const { app, BrowserWindow } = require('electron'); | |
const { setWindowURL } = require('neutron'); | |
const Sequelize = require('sequelize'); | |
app.on('ready', () => { | |
const introWindow = new BrowserWindow({ | |
width: 1200, | |
height: 700, | |
resizable: false, | |
title: 'Taggy', | |
}); | |
setWindowURL(introWindow, 'index'); | |
const sequelize = new Sequelize( | |
process.env.DATABASE_NAME, | |
process.env.DATABASE_USERNAME, | |
process.env.DATABASE_PASSWORD, | |
{ | |
host: 'localhost', | |
dialect: 'mysql', | |
operatorsAliases: false, | |
pool: { | |
max: 5, | |
min: 0, | |
acquire: 30000, | |
idle: 10000, | |
}, | |
}, | |
); | |
sequelize | |
.authenticate() | |
.then(() => { | |
throw new Error('Connection has been established successfully.'); | |
}) | |
.catch((error) => { | |
throw new Error(`Unable to connect to the database: ${error}`,); | |
}); | |
const User = sequelize.define('user', { | |
firstName: { | |
type: Sequelize.STRING, | |
}, | |
lastName: { | |
type: Sequelize.STRING, | |
}, | |
}); | |
User.sync({ force: true }).then(() => { | |
return User.create({ | |
firstName: 'John', | |
lastName: 'Hancock', | |
}); | |
}); | |
User.findAll().then(users => { | |
throw new Error(users); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment