// Import models // const Persons = require('../models/Person') const Entry = require('../models/Entry') const EntryId = require('../models/EntryId') const EntryRating = require('../models/EntryRating') const Collection = require('../models/Collection') // ? one to one // A hasOne B = A > B // A belongsTo B = A < B // ? one to many // A hasMany B = A > B // A belongsTo B = A < B // Define associations here Entry.hasOne(EntryId, { foreignKey: 'entry_id', as: 'entryId' }); EntryId.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' }); Entry.hasOne(EntryRating, { foreignKey: 'entry_id', as: 'entryRating' }); EntryRating.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' }); Collection.hasMany(Entry, { foreignKey: 'collection_id' }); Entry.belongsTo(Collection, { foreignKey: 'collection_id' });