Update: Playlist.create same name and playlist deletd

This commit is contained in:
Yûki VACHOT 2021-12-15 01:13:57 +01:00
parent 4af6891bd5
commit cbb72a8382

View file

@ -41,7 +41,7 @@ exports.create = (req, res) => {
.save(video) .save(video)
.then(data => { .then(data => {
if(data) { if(data) {
Playlist.exists({name: req.body.name}, function (err, docs){ Playlist.exists({name: req.body.name, isActive: true}, function (err, docs){
if(err){ if(err){
sendError(res, 500,100,err.message || "Some error occurred while checking if the Playlist already exists.", token); sendError(res, 500,100,err.message || "Some error occurred while checking if the Playlist already exists.", token);
} else{ } else{
@ -76,7 +76,7 @@ exports.create = (req, res) => {
}); });
} else{ } else{
const id = docs._id.toString(); const id = docs._id.toString();
Playlist.exists({name: req.body.name}, function (err, docs){ Playlist.exists({name: req.body.name, isActive: true}, function (err, docs){
if(err){ if(err){
sendError(res, 500,100,err.message || "Some error occurred while checking if the Playlist already exists.", token); sendError(res, 500,100,err.message || "Some error occurred while checking if the Playlist already exists.", token);
} else{ } else{
@ -108,7 +108,7 @@ exports.create = (req, res) => {
} }
}); });
} else { } else {
Playlist.exists({name: req.body.name}, function (err, docs){ Playlist.exists({name: req.body.name, isActive: true}, function (err, docs){
if(err){ if(err){
sendError(res, 500,100,err.message || "Some error occurred while checking if the Playlist already exists.", token); sendError(res, 500,100,err.message || "Some error occurred while checking if the Playlist already exists.", token);
} else{ } else{