Added and configured sequelize

This commit is contained in:
X4Lo committed 2024-03-31 04:02:50 +00:00
1 parent 772db77e98
commit bf288d5ab7
2 files changed
+46

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
// 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' });