summaryrefslogtreecommitdiff
path: root/nodejs/database/tokens.js
blob: 2a781afd7a6182ad95e514fd1744c3cdb62496f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import db from './db.js';

const addTokenStatement = db.prepare(`INSERT INTO tokens(data) VALUES (?);`);
const getTokenStatement = db.prepare(`SELECT data FROM tokens;`);

export function addToken(token) {
	return addTokenStatement.run(token).lastInsertRowid;
}

export function getToken() {
	const data = getTokenStatement.get();
	if (data === undefined) {
		return null;
	}
	return data.data;
}