From 07cc31ede3a4655c2ea9fa007b02195c37f0a2b7 Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Thu, 21 Sep 2023 11:13:47 +0200 Subject: [PATCH] change cover structure in radio fix #15 --- router/radio.js | 6 +++--- services/database/radios.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/router/radio.js b/router/radio.js index f7ec3d2..aa9e31a 100644 --- a/router/radio.js +++ b/router/radio.js @@ -56,9 +56,9 @@ router if (radio) { if (req.files.file) { resize_image_for_radio(req.files.file.data, (result) => { - radio.cover32 = result.cover32; - radio.cover64 = result.cover64; - radio.cover128 = result.cover128; + radio.covers.cover32 = result.cover32; + radio.covers.cover64 = result.cover64; + radio.covers.cover128 = result.cover128; database.radios.update(radio); res.json(radio).end(); }); diff --git a/services/database/radios.js b/services/database/radios.js index 42359ba..838b1e2 100644 --- a/services/database/radios.js +++ b/services/database/radios.js @@ -23,6 +23,9 @@ exports.byId = function (id, callback) { .collection("radios") .findOne({ _id: ObjectId(id) }, (err, result) => { if (err) throw err; + if (!result.covers) { + result.covers = {}; + } callback(result); }); }; @@ -63,9 +66,7 @@ exports.update = function (radio, callback) { $set: { name: radio.name, url: radio.url, - cover32: radio.cover32, - cover64: radio.cover64, - cover128: radio.cover128 + covers: radio.covers } }, { upsert: false },