mirror of
https://github.com/gnmyt/myspeed.git
synced 2026-01-06 13:09:43 -06:00
Created the config controller
This commit is contained in:
17
server/controller/config.js
Normal file
17
server/controller/config.js
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user