brainz-social-old/database-handler.js

19 lines
721 B
JavaScript
Raw Normal View History

2023-09-27 07:03:36 -05:00
const db = require('better-sqlite3')('brainz-social.db');
db.pragma('journal_mode = WAL');
export default {
db,
getConfig: (key) => {
const row = db.prepare('SELECT * FROM config WHERE key = ?').get(key);
return row.value;
},
setConfig: (key, value) => {
db.prepare("INSERT OR REPLACE INTO config (key, value) VALUES(?, ?);").run(key, value);
},
createApplication: (client_name, redirect_uri, scopes, website, client_id, client_secret) => {
db.prepare("INSERT INTO applications (client_name, redirect_uri, scopes, website, client_id, client_secret) VALUES (?, ?, ?, ?, ?, ?);").run(client_name, redirect_uri, scopes, website, client_id, client_secret);
}
};