From 10916cc468b1ccc6033c26b2db117622cbc648af Mon Sep 17 00:00:00 2001 From: "Gu://em_" Date: Fri, 2 May 2025 11:31:46 +0200 Subject: [PATCH] Minor updates to mod model --- src/models/mod.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/models/mod.js b/src/models/mod.js index 309e177..759116d 100644 --- a/src/models/mod.js +++ b/src/models/mod.js @@ -50,7 +50,7 @@ async function createMod(name, display_name, author, description, mod_infos) { [name, full_description, license.type, links.toString(), creation_date]); // Tags - const tags_proc = updateTags(name, tags, []); + const tags_proc = addTags(name, tags, []); // License if (license_type == "custom") { @@ -73,7 +73,7 @@ async function addVersion(version_number, channel, changelog, release_date, game return; } -async function AddTags(tags) { +async function addTags(tags) { // Add asynchronously const promises = tags.map(async (mod) => { db.query(`INSERT INTO UserFavoriteMods (username, mod) @@ -98,21 +98,11 @@ async function updateMod(name, display_name, author, description) { await updateModAttribute(nale, "author", author); } - if (profile_picture) { - await updateUserAttribute(name, "description", description) + if (description) { + await updateModAttribute(name, "description", description) } } -async function updateModAttribute(name, attribute, value) { - await db.prepare(`UPDATE Mods SET ${attribute} = ? WHERE name = ?`, [value, name]); - return; -} - -async function updateModInfosAttribute(name, attribute, value) { - await db.prepare(`UPDATE ModInfos SET ${attribute} = ? WHERE name = ?`, [value, name]); - return; -} - // --- Delete --- @@ -144,6 +134,19 @@ async function deleteTags(tags) { } +// --- Utils --- + +async function updateModAttribute(name, attribute, value) { + await db.prepare(`UPDATE Mods SET ${attribute} = ? WHERE name = ?`, [value, name]); + return; +} + +async function updateModInfosAttribute(name, attribute, value) { + await db.prepare(`UPDATE ModInfos SET ${attribute} = ? WHERE name = ?`, [value, name]); + return; +} + + // --- Exports --- module.exports = { getAllMods, getModByName, getFullModInfos,