blob: 46b4663838dbd937012d634fdd281d8220a9bb3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import db from './db.js';
const getSystemStatement = db.prepare(`SELECT data from systems where symbol = ?;`);
const setSystemStatement = db.prepare(`INSERT INTO systems(symbol, data) VALUES (?, ?);`);
export function getSystem(symbol) {
try {
const data = getSystemStatement.get(symbol);
if (data === undefined) {
return null;
}
return JSON.parse(data.data);
} catch (err) {
console.log(err);
return null;
}
}
export function setSystem(symbol, data) {
try {
return setSystemStatement.run(symbol, JSON.stringify(data)).lastInsertRowid;
} catch (err) {
console.log(err);
return null;
}
}
|