Continued work on channel-wide playlists.

This commit is contained in:
rainbow napkin 2025-03-25 08:23:58 -04:00
parent 72a89ae5ff
commit 70a68d9336
7 changed files with 151 additions and 89 deletions

View file

@ -605,13 +605,16 @@ channelSchema.methods.addToPlaylist = async function(name, media){
//If the playlist name matches
if(playlist.name == name){
//Push the given media into the found playlist
//this.media.playlists[listIndex].push(media);
//Make note of the found index
foundIndex = listIndex
}
});
//Set media status schema discriminator
media.status = 'saved';
//Add the media to the playlist
this.media.playlists[foundIndex].media.push(media);
//Save the changes made to the chan doc

View file

@ -48,4 +48,5 @@ const mediaSchema = new mongoose.Schema({
}
);
module.exports = mediaSchema;

View file

@ -25,7 +25,8 @@ const playlistMediaProperties = new mongoose.Schema({
uuid: {
type: mongoose.SchemaTypes.UUID,
required:true,
unique: true
unique: true,
default: crypto.randomUUID()
}
},
{

View file

@ -20,7 +20,7 @@ const {mongoose} = require('mongoose');
//Local Imports
const playlistMediaSchema = require('./playlistMediaSchema');
module.exports = new mongoose.Schema({
const playlistSchema = new mongoose.Schema({
name: {
type: mongoose.SchemaTypes.String,
required: true,
@ -31,4 +31,10 @@ module.exports = new mongoose.Schema({
required: true,
default: []
}]
});
});
playlistSchema.methods.test = function(){
console.log(this.name);
}
module.exports = playlistSchema;