add index.js for model management
This commit is contained in:
parent
e5c24e7dee
commit
09cdad0f11
1 changed files with 29 additions and 0 deletions
29
backend/src/models/index.js
Normal file
29
backend/src/models/index.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { sequelize } = require('../config/db');
|
||||||
|
const User = require('./User');
|
||||||
|
const Whiskey = require('./Whiskey');
|
||||||
|
const Collection = require('./Collection');
|
||||||
|
const Rating = require('./Rating');
|
||||||
|
|
||||||
|
// Define relationships
|
||||||
|
|
||||||
|
User.hasMany(Collection);
|
||||||
|
Collection.belongsTo(User);
|
||||||
|
|
||||||
|
Whiskey.hasMany(Collection);
|
||||||
|
Collection.belongsTo(Whiskey);
|
||||||
|
|
||||||
|
User.hasMany(Rating);
|
||||||
|
Rating.belongsTo(User);
|
||||||
|
|
||||||
|
Whiskey.hasMany(Rating);
|
||||||
|
Rating.belongsTo(Whiskey);
|
||||||
|
|
||||||
|
// Exports
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
User,
|
||||||
|
Whiskey,
|
||||||
|
Collection,
|
||||||
|
Rating,
|
||||||
|
sequelize
|
||||||
|
};
|
Loading…
Reference in a new issue