From b3e5fe3888be93f187404ef5529b3696ab1caaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Sun, 12 Dec 2021 07:03:01 +0100 Subject: [PATCH] Update: Playlist.create --- app-backend/controllers/video.controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app-backend/controllers/video.controller.js b/app-backend/controllers/video.controller.js index bab0bb8..77b68af 100644 --- a/app-backend/controllers/video.controller.js +++ b/app-backend/controllers/video.controller.js @@ -261,10 +261,10 @@ exports.create = (req, res) => { }); } else{ const id = docs._id.toString(); - Video.findByIdAndUpdate(id, {$push: {watchedDates: [new Date()]}}, {useFindAndModify: false}) + Video.findByIdAndUpdate(id, {$push: {watchedDates: [new Date()]}}, {useFindAndModify: false, new: true}) .then(data => { if(data) { - return sendMessage(res, 33, {message: `Video ${id} was successfully updated.`}, token); + return sendMessage(res, 33, data, token); } else { return sendError(res, 404, 105, `Video not found with id=${id}`, token); } @@ -408,7 +408,7 @@ exports.update = (req, res) => { Object.keys(update).forEach(key => update[key] === undefined ? delete update[key] : {}); if(id && ObjectId.isValid(id)){ - Video.updateOne({_id: id, userId: token.id}, update) + Video.updateOne({_id: id, userId: token.id, isActive: true}, update) .then(data => { if(data) { return sendMessage(res, 36, update, token);