kuru-kuru/shared/db.ts
Ayase Minori 41be1559f1
refactor: Update dependencies and refactor code (#18)
* refactor: Update dependencies and refactor code

Removed axios-web and replaced with BroadcastChannel and WebSocket for counter and global count functionalities.

* feat: Update CounterCard and routes

Update CounterCard timeout and routes POST method

* Debug socket message

* ensure value is always treated as a BigInt internally

* Frogot to put it below that 💀

* Move type conversion to database

* I swear if this doesnt work im going to choke someone

* assign converted value to a variable

SURELY this will work right?

* Revert db to use numbers again
2023-10-24 00:11:50 +08:00

11 lines
317 B
TypeScript

const kv = await Deno.openKv();
export async function getGlobalStatistics() {
const res = await kv.get<number>(["global-statistics"])!;
return res.value!;
}
export async function setGlobalStatistics(value: number) {
const pv = await getGlobalStatistics();
await kv.set(["global-statistics"], pv + value);
}