Update: Playlist.update videoIds + videoId fields
This commit is contained in:
parent
2bc7c968ef
commit
3ffb579ed6
1 changed files with 12 additions and 5 deletions
|
|
@ -316,12 +316,19 @@ exports.update = (req, res) => {
|
||||||
update.name = condition;
|
update.name = condition;
|
||||||
|
|
||||||
const videoIds = req.body.videoIds;
|
const videoIds = req.body.videoIds;
|
||||||
if(typeof videoIds !== 'undefined' && videoIds !== null){
|
condition = videoIds ? videoIds : undefined;
|
||||||
condition = videoIds ? {videoIds: videoIds} : undefined;
|
update.videoIds = condition;
|
||||||
} else {
|
|
||||||
condition = undefined;
|
const videoId = req.body.videoId;
|
||||||
|
if(typeof videoId !== 'undefined' && typeof videoId.id !== 'undefined' && typeof videoId.action !== 'undefined'){
|
||||||
|
if(videoId.action === 'add'){
|
||||||
|
condition = videoId.id ? {videoIds: videoId.id} : undefined;
|
||||||
|
update.$addToSet = condition;
|
||||||
|
} else if(videoId.action === 'delete'){
|
||||||
|
condition = videoId.id ? {videoIds: videoId.id} : undefined;
|
||||||
|
update.$pull = condition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
update.$addToSet = condition;
|
|
||||||
|
|
||||||
const isActive = req.body.isActive;
|
const isActive = req.body.isActive;
|
||||||
if(typeof isActive !== 'undefined'){
|
if(typeof isActive !== 'undefined'){
|
||||||
|
|
|
||||||
Reference in a new issue