Created the config controller

This commit is contained in:
Mathias Wagner
2022-04-06 21:44:51 +02:00
parent 0b003cee2e
commit 5d7b21e1b1

View File

@@ -0,0 +1,17 @@
const db = require('../index').database;
// Lists all config entries
module.exports.list = () => {
return db.prepare("SELECT * FROM config").all();
}
// Gets a specific config entry
module.exports.get = (key) => {
return db.prepare("SELECT * FROM config WHERE key = ?").get(key);
}
// Updates a specific config entry
module.exports.update = (key, newValue) => {
if (this.get(key) === undefined) return undefined;
return db.prepare("UPDATE config SET value = ? WHERE key = ?").run(newValue, key);
}