diff options
author | Julien Dessaux | 2023-10-20 00:17:31 +0200 |
---|---|---|
committer | Julien Dessaux | 2023-10-20 00:17:31 +0200 |
commit | 6cf84fe67f3a6232753a97afc8a41a07e759d1b0 (patch) | |
tree | cb54468eb200f51ab1baf9621d43969d9ba73d01 /nodejs/database | |
parent | [javascript] implemented contract fulfillment (diff) | |
download | spacetraders-6cf84fe67f3a6232753a97afc8a41a07e759d1b0.tar.gz spacetraders-6cf84fe67f3a6232753a97afc8a41a07e759d1b0.tar.bz2 spacetraders-6cf84fe67f3a6232753a97afc8a41a07e759d1b0.zip |
[javascript] Track credits on contract fulfillment
Diffstat (limited to '')
-rw-r--r-- | nodejs/database/agents.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/nodejs/database/agents.js b/nodejs/database/agents.js index 4dd7f4b..8b7203b 100644 --- a/nodejs/database/agents.js +++ b/nodejs/database/agents.js @@ -2,6 +2,7 @@ import db from './db.js'; 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) { return addAgentStatement.run(JSON.stringify(agent)).lastInsertRowid; @@ -14,3 +15,7 @@ export function getAgent() { } return JSON.parse(data.data); } + +export function setAgent(agent) { + return setAgentStatement.run(JSON.stringify(agent)).changes; +} |