add networks + random changes

This commit is contained in:
X4Lo committed 2025-02-15 23:40:34 +01:00
1 parent bb36b2bd44
commit 5dc5a023b8
26 files changed
+1399 -1975

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
const Collection = require("../models/Collection");
const Entry = require("../models/Entry");
const EntryId = require("../models/EntryId");
const EntryRating = require("../models/EntryRating");
const Genre = require("../models/Genre");
const Media = require("../models/Media");
const Network = require("../models/Network");
const Season = require("../models/Season");
class NetworkService {
constructor() {
if (!NetworkService.instance) {
NetworkService.instance = this;
}
return NetworkService.instance;
}
async getNetworks() {
const networks = await Network.findAll({
include: [
{
model: Entry, as: 'entries',
include: { model: Media, as: 'medias' }
}
],
order: [['name', 'ASC']]
});
return networks;
}
async getNetworkById(id) {
const network = await Network.findByPk(id, {
include: [{
model: Entry,
as: 'entries',
include: [
{ model: EntryId, as: 'entryId' },
{ model: EntryRating, as: 'entryRating' },
{ model: Season, as: 'seasons' },
{ model: Media, as: 'medias' },
{ model: Genre, as: 'genres' },
]
}]
});
return network;
}
async createOrUpdateNetwork(networkData) {
return await Network.findOrCreate({
where: { id: networkData.id },
defaults: {
id: networkData.id,
name: networkData.name,
originCountry: networkData.originCountry,
homepage: networkData.homepage,
logoPath: networkData.logoPath,
posterPath: networkData.posterPath,
backdropPath: networkData.backdropPath,
}
});
}
}
module.exports = new NetworkService();