TheOchulus/dbObjects.js

22 lines
676 B
JavaScript
Raw Normal View History

2023-12-18 22:56:59 +01:00
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
});
const Users = require('./models/users.js')(sequelize, Sequelize.DataTypes);
const Games = require('./models/games.js')(sequelize, Sequelize.DataTypes);
const BeatenGames = require('./models/beatenGames.js')(sequelize, Sequelize.DataTypes);
// Create userId foreignKey
Users.hasMany(BeatenGames);
BeatenGames.belongsTo(Users);
// Create gameId foreignKey
Games.hasMany(BeatenGames);
BeatenGames.belongsTo(Games);
module.exports = { Users, Games, BeatenGames };