Continued work on channel-wide playlists.
This commit is contained in:
parent
72a89ae5ff
commit
70a68d9336
7 changed files with 151 additions and 89 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -48,4 +48,5 @@ const mediaSchema = new mongoose.Schema({
|
|||
}
|
||||
);
|
||||
|
||||
|
||||
module.exports = mediaSchema;
|
||||
|
|
@ -25,7 +25,8 @@ const playlistMediaProperties = new mongoose.Schema({
|
|||
uuid: {
|
||||
type: mongoose.SchemaTypes.UUID,
|
||||
required:true,
|
||||
unique: true
|
||||
unique: true,
|
||||
default: crypto.randomUUID()
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue