summaryrefslogtreecommitdiff
path: root/nodejs/database/surveys.ts
blob: 649280509f1770925990b716fdf1a4984a76cec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { DbData, db } from './db.ts';

//const deleteExpiredSurveysStatement = db.prepare(`DELETE FROM surveys WHERE data->>'expiration' < ?;`);
//const getSurveysStatement = db.prepare(`SELECT data FROM surveys WHERE data->>'symbol' = ?;`);
//const setSurveysStatement = db.prepare(`INSERT INTO surveys(data) VALUES (json(?));`);
//
//export function deleteExpired() {
//	return deleteExpiredSurveysStatement.run(new Date().toISOString()).changes;
//}
//
//export function get(symbol) {
//	deleteExpired();
//	const data = getSurveysStatement.all(symbol);
//	return data.map(elt => JSON.parse(elt.data));
//}
//
//export function set(survey) {
//	deleteExpired();
//	return setSurveysStatement.run(JSON.stringify(survey));
//}