diff --git a/backend/src/models/index.js b/backend/src/models/index.js new file mode 100644 index 0000000..bace54f --- /dev/null +++ b/backend/src/models/index.js @@ -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 +};