diff --git a/backend/src/admin/options.ts b/backend/src/admin/options.ts index 9b06634..87c740e 100644 --- a/backend/src/admin/options.ts +++ b/backend/src/admin/options.ts @@ -7,6 +7,7 @@ import { files } from '../resources/files.js'; import { playlists } from '../resources/playlists.js'; import { thumbnails } from '../resources/thumbnail.js'; import { trailers } from '../resources/trailer.js'; +import { sites } from '../resources/site.js'; import { componentLoader } from './component-loader.js'; @@ -23,6 +24,7 @@ const options: AdminJSOptions = { playlists, thumbnails, trailers, + sites, ], databases: [], dashboard: { diff --git a/backend/src/models/playlist.ts b/backend/src/models/playlist.ts index e98dd0a..3c57afa 100644 --- a/backend/src/models/playlist.ts +++ b/backend/src/models/playlist.ts @@ -3,6 +3,7 @@ import { Document, Schema, model } from 'mongoose'; // Define Playlist interface export interface IPlaylist extends Document { name: string; + site: Schema.Types.ObjectId; } // Define playlist schema @@ -12,6 +13,7 @@ export const playlistSchema = new Schema({ unique: true, required: true, }, + site: { type: Schema.Types.ObjectId, ref: 'Site' }, }); const Playlist = model('Playlist', playlistSchema); diff --git a/backend/src/models/site.ts b/backend/src/models/site.ts new file mode 100644 index 0000000..45c140f --- /dev/null +++ b/backend/src/models/site.ts @@ -0,0 +1,18 @@ +import { Document, Schema, model } from 'mongoose'; + +// Define Site interface +export interface ISite extends Document { + name: string; +} + +// Define site schema +export const siteSchema = new Schema({ + name: { + type: String, + unique: true, + required: true, + }, +}); + +const Site = model('Site', siteSchema); +export default Site; diff --git a/backend/src/resources/playlists.ts b/backend/src/resources/playlists.ts index d6b7abc..6bc9b64 100644 --- a/backend/src/resources/playlists.ts +++ b/backend/src/resources/playlists.ts @@ -7,6 +7,10 @@ export const playlists = { name: { type: 'string', }, + site: { + type: 'reference', + reference: 'Site', + }, }, }, }; diff --git a/backend/src/resources/site.ts b/backend/src/resources/site.ts new file mode 100644 index 0000000..1140f28 --- /dev/null +++ b/backend/src/resources/site.ts @@ -0,0 +1,12 @@ +import Site from '../models/site.js'; + +export const sites = { + resource: Site, + options: { + properties: { + name: { + type: 'string', + }, + }, + }, +};