Minor updates to mod model

This commit is contained in:
Gu://em_ 2025-05-02 11:31:46 +02:00
parent c379978f0d
commit 10916cc468

View file

@ -50,7 +50,7 @@ async function createMod(name, display_name, author, description, mod_infos) {
[name, full_description, license.type, links.toString(), creation_date]); [name, full_description, license.type, links.toString(), creation_date]);
// Tags // Tags
const tags_proc = updateTags(name, tags, []); const tags_proc = addTags(name, tags, []);
// License // License
if (license_type == "custom") { if (license_type == "custom") {
@ -73,7 +73,7 @@ async function addVersion(version_number, channel, changelog, release_date, game
return; return;
} }
async function AddTags(tags) { async function addTags(tags) {
// Add asynchronously // Add asynchronously
const promises = tags.map(async (mod) => { const promises = tags.map(async (mod) => {
db.query(`INSERT INTO UserFavoriteMods (username, 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); await updateModAttribute(nale, "author", author);
} }
if (profile_picture) { if (description) {
await updateUserAttribute(name, "description", 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 --- // --- 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 --- // --- Exports ---
module.exports = { getAllMods, getModByName, getFullModInfos, module.exports = { getAllMods, getModByName, getFullModInfos,