summaryrefslogtreecommitdiff
path: root/nodejs/database
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-15 23:49:33 +0200
committerJulien Dessaux2024-05-15 23:49:33 +0200
commit6504e44ffa97965e47e893b55621d2d04003d519 (patch)
tree18b416bdd03988b5e2215e8e4c1771b06e7f4084 /nodejs/database
parent[node] updated dependencies (diff)
downloadspacetraders-6504e44ffa97965e47e893b55621d2d04003d519.tar.gz
spacetraders-6504e44ffa97965e47e893b55621d2d04003d519.tar.bz2
spacetraders-6504e44ffa97965e47e893b55621d2d04003d519.zip
[node] Added agent class, and fixed contract updates
Diffstat (limited to '')
-rw-r--r--nodejs/database/agents.ts20
1 files changed, 0 insertions, 20 deletions
diff --git a/nodejs/database/agents.ts b/nodejs/database/agents.ts
deleted file mode 100644
index 5221dc7..0000000
--- a/nodejs/database/agents.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Agent } from '../lib/types.ts';
-import { DbData, db } from './db.ts';
-
-const addAgentStatement = db.prepare(`INSERT INTO agents(data) VALUES (json(?));`);
-const getAgentStatement = db.prepare(`SELECT data FROM agents;`);
-const setAgentStatement = db.prepare(`UPDATE agents SET data = json(?);`);
-
-export function addAgent(agent: Agent): void {
- addAgentStatement.run(JSON.stringify(agent));
-}
-
-export function getAgent(): Agent|null {
- const data = getAgentStatement.get() as DbData|undefined;
- if (!data) return null;
- return JSON.parse(data.data);
-}
-
-export function setAgent(agent: Agent): void {
- setAgentStatement.run(JSON.stringify(agent));
-}