add networks + random changes
This commit is contained in:
1 parent
bb36b2bd44
commit
5dc5a023b8
26 files changed
+1399
-1975
No files matched your search
@@ -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();
|
||||
Reference in new issue
Block a user