Skip to content

Instantly share code, notes, and snippets.

@SilencerWeb
Created September 26, 2018 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilencerWeb/5d0c121f779712ddc72dc46dea4aae43 to your computer and use it in GitHub Desktop.
Save SilencerWeb/5d0c121f779712ddc72dc46dea4aae43 to your computer and use it in GitHub Desktop.
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