[javascript] reworked basic exploration with systems fetch after registering
This commit is contained in:
parent
e52662f829
commit
14f81bcc1b
2 changed files with 15 additions and 16 deletions
|
@ -3,6 +3,7 @@ import db from './db.js';
|
|||
const addSystemStatement = db.prepare(`INSERT INTO systems(data) VALUES (json(?));`);
|
||||
const getSystemStatement = db.prepare(`SELECT data FROM systems WHERE data->>'symbol' = ?;`);
|
||||
const getSystemUpdatedStatement = db.prepare(`SELECT updated FROM systems WHERE data->>'symbol' = ?;`);
|
||||
const getSystemsCountStatement = db.prepare(`SELECT COUNT(data) as data FROM systems;`);
|
||||
const setSystemWaypointsStatement = db.prepare(`UPDATE systems SET data = (SELECT json_set(data, '$.waypoints', json(:waypoints)) FROM systems WHERE data->>'symbol' = :symbol), updated = :date WHERE data->>'symbol' = :symbol;`);
|
||||
|
||||
export function addSystem(data) {
|
||||
|
@ -17,6 +18,14 @@ export function getSystem(symbol) {
|
|||
return JSON.parse(data.data);
|
||||
}
|
||||
|
||||
export function getSystemsCount() {
|
||||
const data = getSystemsCountStatement.get();
|
||||
if (data === undefined) {
|
||||
return null;
|
||||
}
|
||||
return data.data;
|
||||
}
|
||||
|
||||
export function getSystemUpdated(symbol) {
|
||||
const updated = getSystemUpdatedStatement.get(symbol);
|
||||
if (updated === undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue