[javascript] added contracts and agent database management
This commit is contained in:
parent
9a71163dda
commit
e03bb90611
4 changed files with 53 additions and 1 deletions
16
nodejs/database/agents.js
Normal file
16
nodejs/database/agents.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
import db from './db.js';
|
||||
|
||||
const addAgentStatement = db.prepare(`INSERT INTO agents(data) VALUES (json(?));`);
|
||||
const getAgentStatement = db.prepare(`SELECT data FROM agents;`);
|
||||
|
||||
export function addAgent(agent) {
|
||||
return addAgentStatement.run(JSON.stringify(agent)).lastInsertRowid;
|
||||
}
|
||||
|
||||
export function getAgent() {
|
||||
const data = getAgentStatement.get();
|
||||
if (data === undefined) {
|
||||
return null;
|
||||
}
|
||||
return data.data;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue