rename model list to usercollection & fixed redlated errors

This commit is contained in:
X4Lo committed 2024-04-06 08:56:16 +00:00
1 parent 60b517500f
commit b48b395574
37 files changed
+2479 -1210

No files matched your search

+16 -16
View File
@@ -1,11 +1,11 @@
// Import models
const Collection = require('../models/Collection');
const Franchise = require('../models/Franchise');
const Entry = require('../models/Entry')
const EntryId = require('../models/EntryId')
const EntryRating = require('../models/EntryRating')
const EntrySeen = require('../models/EntrySeen');
const List = require('../models/List');
const ListEntry = require('../models/ListEntry');
const UserCollection = require('../models/UserCollection');
const UserCollectionEntry = require('../models/UserCollectionEntry');
const Season = require('../models/Season');
const Episode = require('../models/Episode');
const EpisodeSeen = require('../models/EpisodeSeen');
@@ -36,26 +36,26 @@ Entry.hasMany(EntrySeen, { foreignKey: 'entry_id', onDelete: 'CASCADE', });
EntrySeen.belongsTo(Entry, { foreignKey: 'entry_id' });
// * ENTRY & LIST - MANY TO MANY
Entry.belongsToMany(List, {
through: ListEntry,
Entry.belongsToMany(UserCollection, {
through: UserCollectionEntry,
foreignKey: 'entry_id',
otherKey: 'list_id',
otherKey: 'user_collection_id',
onDelete: 'CASCADE',
as: 'entries',
as: 'userCollections',
});
List.belongsToMany(Entry, {
through: ListEntry,
foreignKey: 'list_id',
UserCollection.belongsToMany(Entry, {
through: UserCollectionEntry,
foreignKey: 'user_collection_id',
otherKey: 'entry_id',
onDelete: 'CASCADE',
as: 'entries',
});
Entry.hasMany(ListEntry, { foreignKey: 'entry_id', as: 'listEntries' });
ListEntry.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
List.hasMany(ListEntry, { foreignKey: 'list_id', as: 'listEntries' });
ListEntry.belongsTo(List, { foreignKey: 'list_id', as: 'list' });
Entry.hasMany(UserCollectionEntry, { foreignKey: 'entry_id', as: 'userCollectionEntries' });
UserCollectionEntry.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
UserCollection.hasMany(UserCollectionEntry, { foreignKey: 'user_collection_id', as: 'userCollectionEntries' });
UserCollectionEntry.belongsTo(UserCollection, { foreignKey: 'user_collection_id', as: 'userCollection' });
// * ENTRY & SEASON - ONE TO MANY
Entry.hasMany(Season, { foreignKey: 'entry_id', onDelete: 'CASCADE', });
@@ -69,5 +69,5 @@ Episode.belongsTo(Season, { foreignKey: 'season_id' });
Episode.hasMany(EpisodeSeen, { foreignKey: 'episode_id', onDelete: 'CASCADE', });
EpisodeSeen.belongsTo(Episode, { foreignKey: 'episode_id' });
Collection.hasMany(Entry, { foreignKey: 'collection_id' });
Entry.belongsTo(Collection, { foreignKey: 'collection_id' });
Franchise.hasMany(Entry, { foreignKey: 'franchise_id' });
Entry.belongsTo(Franchise, { foreignKey: 'franchise_id' });