From 6504e44ffa97965e47e893b55621d2d04003d519 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 15 May 2024 23:49:33 +0200 Subject: [node] Added agent class, and fixed contract updates --- nodejs/database/agents.ts | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 nodejs/database/agents.ts (limited to 'nodejs/database') 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)); -} -- cgit v1.2.3