Normalize to double quotes across all files with Prettier
This commit is contained in:
1 parent
73bff72cec
commit
a5659cf4c8
190 files changed
+9523
-8859
No files matched your search
+131
-106
@@ -1,22 +1,21 @@
|
||||
// Import models
|
||||
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 Collection = require('../models/Collection');
|
||||
const UserCollectionEntry = require('../models/UserCollectionEntry');
|
||||
const Season = require('../models/Season');
|
||||
const Episode = require('../models/Episode');
|
||||
const EpisodeSeen = require('../models/EpisodeSeen');
|
||||
const Genre = require('../models/Genre');
|
||||
const EntryGenre = require('../models/EntryGenre');
|
||||
const Media = require('../models/Media');
|
||||
const Network = require('../models/Network');
|
||||
const EntryNetwork = require('../models/EntryNetwork');
|
||||
const People = require('../models/People');
|
||||
const Credit = require('../models/Credit');
|
||||
|
||||
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 Collection = require("../models/Collection");
|
||||
const UserCollectionEntry = require("../models/UserCollectionEntry");
|
||||
const Season = require("../models/Season");
|
||||
const Episode = require("../models/Episode");
|
||||
const EpisodeSeen = require("../models/EpisodeSeen");
|
||||
const Genre = require("../models/Genre");
|
||||
const EntryGenre = require("../models/EntryGenre");
|
||||
const Media = require("../models/Media");
|
||||
const Network = require("../models/Network");
|
||||
const EntryNetwork = require("../models/EntryNetwork");
|
||||
const People = require("../models/People");
|
||||
const Credit = require("../models/Credit");
|
||||
|
||||
// ? one to one
|
||||
// A hasOne B = A > B
|
||||
@@ -25,197 +24,223 @@ const Credit = require('../models/Credit');
|
||||
// A hasMany B = A > B
|
||||
// A belongsTo B = A < B
|
||||
|
||||
|
||||
// * ENTRY & EntryId - ONE TO ONE
|
||||
Entry.hasOne(EntryId, {
|
||||
foreignKey: 'entry_id', as: 'entryId', onDelete: 'CASCADE',
|
||||
foreignKey: "entry_id",
|
||||
as: "entryId",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
EntryId.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
EntryId.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
|
||||
// * ENTRY & EntryRating - ONE TO ONE
|
||||
Entry.hasOne(EntryRating, {
|
||||
foreignKey: 'entry_id', as: 'entryRating', onDelete: 'CASCADE',
|
||||
foreignKey: "entry_id",
|
||||
as: "entryRating",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
EntryRating.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
EntryRating.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
|
||||
// * ENTRY & ENTRY_SEEN - ONE TO MANY
|
||||
Entry.hasMany(EntrySeen, {
|
||||
foreignKey: 'entry_id', as: 'entrySeen', onDelete: 'CASCADE',
|
||||
foreignKey: "entry_id",
|
||||
as: "entrySeen",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
EntrySeen.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
EntrySeen.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
|
||||
// * ENTRY & LIST - MANY TO MANY
|
||||
Entry.belongsToMany(Collection, {
|
||||
through: UserCollectionEntry,
|
||||
foreignKey: 'entry_id',
|
||||
otherKey: 'user_collection_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'collections',
|
||||
foreignKey: "entry_id",
|
||||
otherKey: "user_collection_id",
|
||||
onDelete: "CASCADE",
|
||||
as: "collections",
|
||||
});
|
||||
|
||||
Collection.belongsToMany(Entry, {
|
||||
through: UserCollectionEntry,
|
||||
foreignKey: 'user_collection_id',
|
||||
otherKey: 'entry_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'entries',
|
||||
foreignKey: "user_collection_id",
|
||||
otherKey: "entry_id",
|
||||
onDelete: "CASCADE",
|
||||
as: "entries",
|
||||
});
|
||||
|
||||
Entry.hasMany(UserCollectionEntry, { foreignKey: 'entry_id', as: 'userCollectionEntries' });
|
||||
UserCollectionEntry.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
Collection.hasMany(UserCollectionEntry, { foreignKey: 'user_collection_id', as: 'userCollectionEntries' });
|
||||
UserCollectionEntry.belongsTo(Collection, { foreignKey: 'user_collection_id', as: 'userCollection' });
|
||||
Entry.hasMany(UserCollectionEntry, {
|
||||
foreignKey: "entry_id",
|
||||
as: "userCollectionEntries",
|
||||
});
|
||||
UserCollectionEntry.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
Collection.hasMany(UserCollectionEntry, {
|
||||
foreignKey: "user_collection_id",
|
||||
as: "userCollectionEntries",
|
||||
});
|
||||
UserCollectionEntry.belongsTo(Collection, {
|
||||
foreignKey: "user_collection_id",
|
||||
as: "userCollection",
|
||||
});
|
||||
|
||||
// * ENTRY & GENRE - MANY TO MANY
|
||||
Entry.belongsToMany(Genre, {
|
||||
through: EntryGenre,
|
||||
foreignKey: 'entry_id',
|
||||
otherKey: 'genre_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'genres',
|
||||
foreignKey: "entry_id",
|
||||
otherKey: "genre_id",
|
||||
onDelete: "CASCADE",
|
||||
as: "genres",
|
||||
});
|
||||
|
||||
Genre.belongsToMany(Entry, {
|
||||
through: EntryGenre,
|
||||
foreignKey: 'genre_id',
|
||||
otherKey: 'entry_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'entries',
|
||||
foreignKey: "genre_id",
|
||||
otherKey: "entry_id",
|
||||
onDelete: "CASCADE",
|
||||
as: "entries",
|
||||
});
|
||||
|
||||
Entry.hasMany(EntryGenre, { foreignKey: 'entry_id', as: 'entryGenres' });
|
||||
EntryGenre.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
Genre.hasMany(EntryGenre, { foreignKey: 'genre_id', as: 'entryGenres' });
|
||||
EntryGenre.belongsTo(Genre, { foreignKey: 'genre_id', as: 'genre' });
|
||||
Entry.hasMany(EntryGenre, { foreignKey: "entry_id", as: "entryGenres" });
|
||||
EntryGenre.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
Genre.hasMany(EntryGenre, { foreignKey: "genre_id", as: "entryGenres" });
|
||||
EntryGenre.belongsTo(Genre, { foreignKey: "genre_id", as: "genre" });
|
||||
|
||||
// * ENTRY & NETWORK - MANY TO MANY
|
||||
Entry.belongsToMany(Network, {
|
||||
through: EntryNetwork,
|
||||
foreignKey: 'entry_id',
|
||||
otherKey: 'network_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'networks',
|
||||
foreignKey: "entry_id",
|
||||
otherKey: "network_id",
|
||||
onDelete: "CASCADE",
|
||||
as: "networks",
|
||||
});
|
||||
|
||||
Network.belongsToMany(Entry, {
|
||||
through: EntryNetwork,
|
||||
foreignKey: 'network_id',
|
||||
otherKey: 'entry_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'entries',
|
||||
foreignKey: "network_id",
|
||||
otherKey: "entry_id",
|
||||
onDelete: "CASCADE",
|
||||
as: "entries",
|
||||
});
|
||||
|
||||
// ! MEDIA
|
||||
// * MEDIA & ENTRY - MANY TO ONE
|
||||
Media.belongsTo(Entry, {
|
||||
foreignKey: 'mediaableId',
|
||||
as: 'entry',
|
||||
foreignKey: "mediaableId",
|
||||
as: "entry",
|
||||
constraints: false,
|
||||
where: {
|
||||
mediaable: 'entry'
|
||||
}
|
||||
mediaable: "entry",
|
||||
},
|
||||
});
|
||||
|
||||
Entry.hasMany(Media, {
|
||||
foreignKey: 'mediaableId',
|
||||
foreignKey: "mediaableId",
|
||||
constraints: false,
|
||||
as: 'medias',
|
||||
scope: { mediaable: 'entry' }
|
||||
as: "medias",
|
||||
scope: { mediaable: "entry" },
|
||||
});
|
||||
|
||||
// * MEDIA & People - MANY TO ONE
|
||||
Media.belongsTo(People, {
|
||||
foreignKey: 'mediaableId',
|
||||
as: 'people',
|
||||
foreignKey: "mediaableId",
|
||||
as: "people",
|
||||
constraints: false,
|
||||
where: {
|
||||
mediaable: 'people'
|
||||
}
|
||||
mediaable: "people",
|
||||
},
|
||||
});
|
||||
|
||||
People.hasMany(Media, {
|
||||
foreignKey: 'mediaableId',
|
||||
foreignKey: "mediaableId",
|
||||
constraints: false,
|
||||
as: 'medias',
|
||||
scope: { mediaable: 'people' }
|
||||
as: "medias",
|
||||
scope: { mediaable: "people" },
|
||||
});
|
||||
|
||||
// * MEDIA & Collection - MANY TO ONE
|
||||
Media.belongsTo(Collection, {
|
||||
foreignKey: 'mediaableId',
|
||||
as: 'collection',
|
||||
foreignKey: "mediaableId",
|
||||
as: "collection",
|
||||
constraints: false,
|
||||
where: {
|
||||
mediaable: 'collection'
|
||||
}
|
||||
mediaable: "collection",
|
||||
},
|
||||
});
|
||||
|
||||
Collection.hasMany(Media, {
|
||||
foreignKey: 'mediaableId',
|
||||
foreignKey: "mediaableId",
|
||||
constraints: false,
|
||||
as: 'medias',
|
||||
scope: { mediaable: 'collection' }
|
||||
as: "medias",
|
||||
scope: { mediaable: "collection" },
|
||||
});
|
||||
|
||||
// * MEDIA & Season - MANY TO ONE
|
||||
Media.belongsTo(Season, {
|
||||
foreignKey: 'mediaableId',
|
||||
as: 'season',
|
||||
foreignKey: "mediaableId",
|
||||
as: "season",
|
||||
constraints: false,
|
||||
where: {
|
||||
mediaable: 'season'
|
||||
}
|
||||
mediaable: "season",
|
||||
},
|
||||
});
|
||||
|
||||
Season.hasMany(Media, {
|
||||
foreignKey: 'mediaableId',
|
||||
foreignKey: "mediaableId",
|
||||
constraints: false,
|
||||
as: 'medias',
|
||||
scope: { mediaable: 'season' }
|
||||
as: "medias",
|
||||
scope: { mediaable: "season" },
|
||||
});
|
||||
|
||||
// * MEDIA & Episode - MANY TO ONE
|
||||
Media.belongsTo(Episode, {
|
||||
foreignKey: 'mediaableId',
|
||||
as: 'episode',
|
||||
foreignKey: "mediaableId",
|
||||
as: "episode",
|
||||
constraints: false,
|
||||
where: {
|
||||
mediaable: 'episode'
|
||||
}
|
||||
mediaable: "episode",
|
||||
},
|
||||
});
|
||||
|
||||
Episode.hasMany(Media, {
|
||||
foreignKey: 'mediaableId',
|
||||
foreignKey: "mediaableId",
|
||||
constraints: false,
|
||||
as: 'medias',
|
||||
scope: { mediaable: 'episode' }
|
||||
as: "medias",
|
||||
scope: { mediaable: "episode" },
|
||||
});
|
||||
// ! MEDIA END
|
||||
|
||||
// * ENTRY & SEASON - ONE TO MANY
|
||||
Entry.hasMany(Season, { foreignKey: 'entry_id', as: 'seasons', onDelete: 'CASCADE', });
|
||||
Season.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
Entry.hasMany(Season, {
|
||||
foreignKey: "entry_id",
|
||||
as: "seasons",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
Season.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
|
||||
// * SEASON & EPISODE - ONE TO MANY
|
||||
Season.hasMany(Episode, { foreignKey: 'season_id', onDelete: 'CASCADE', });
|
||||
Episode.belongsTo(Season, { foreignKey: 'season_id' });
|
||||
Season.hasMany(Episode, { foreignKey: "season_id", onDelete: "CASCADE" });
|
||||
Episode.belongsTo(Season, { foreignKey: "season_id" });
|
||||
|
||||
// * EPISODE & EPISODE_SEEN - ONE TO MANY
|
||||
Episode.hasMany(EpisodeSeen, { foreignKey: 'episode_id', onDelete: 'CASCADE', });
|
||||
EpisodeSeen.belongsTo(Episode, { foreignKey: 'episode_id' });
|
||||
Episode.hasMany(EpisodeSeen, { foreignKey: "episode_id", onDelete: "CASCADE" });
|
||||
EpisodeSeen.belongsTo(Episode, { foreignKey: "episode_id" });
|
||||
|
||||
// * ENTRY & EPISODE_SEEN - ONE TO MANY
|
||||
Entry.hasMany(EpisodeSeen, { foreignKey: 'entry_id', onDelete: 'CASCADE', });
|
||||
EpisodeSeen.belongsTo(Entry, { foreignKey: 'entry_id' });
|
||||
Entry.hasMany(EpisodeSeen, { foreignKey: "entry_id", onDelete: "CASCADE" });
|
||||
EpisodeSeen.belongsTo(Entry, { foreignKey: "entry_id" });
|
||||
|
||||
// * ----
|
||||
Franchise.hasMany(Entry, { foreignKey: 'franchise_id' });
|
||||
Entry.belongsTo(Franchise, { foreignKey: 'franchise_id' });
|
||||
Franchise.hasMany(Entry, { foreignKey: "franchise_id" });
|
||||
Entry.belongsTo(Franchise, { foreignKey: "franchise_id" });
|
||||
|
||||
// * ENTRY & Credit - ONE TO MANY
|
||||
Entry.hasMany(Credit, { foreignKey: 'entry_id', as: 'credits', onDelete: 'CASCADE', });
|
||||
Credit.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
Entry.hasMany(Credit, {
|
||||
foreignKey: "entry_id",
|
||||
as: "credits",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
Credit.belongsTo(Entry, { foreignKey: "entry_id", as: "entry" });
|
||||
|
||||
// * PEOPLE & CAST - ONE TO MANY
|
||||
People.hasMany(Credit, { foreignKey: 'people_id', as: 'roles', onDelete: 'CASCADE', });
|
||||
Credit.belongsTo(People, { foreignKey: 'people_id', as: 'person' });
|
||||
People.hasMany(Credit, {
|
||||
foreignKey: "people_id",
|
||||
as: "roles",
|
||||
onDelete: "CASCADE",
|
||||
});
|
||||
Credit.belongsTo(People, { foreignKey: "people_id", as: "person" });
|
||||
Reference in new issue
Block a user