feat: Update globalCount type to bigint

Update globalCount type from number to bigint in CounterCard and index files, and in setGlobalStatistics function
This commit is contained in:
Ayane Satomi 2023-10-22 05:56:36 +00:00
parent f2abd5110c
commit 238c01bcd7
3 changed files with 5 additions and 5 deletions

View file

@ -3,7 +3,7 @@ import { useEffect, useState } from "preact/hooks";
import axios from "axios-web";
interface SharedProps {
globalCount: number;
globalCount: bigint;
audioFiles: string[];
}

View file

@ -78,7 +78,7 @@ export const handler: Handlers = {
};
export default function Home(
{ data: { globalCount } }: { data: { globalCount: number } },
{ data: { globalCount } }: { data: { globalCount: bigint } },
) {
// added a pseudo-div here so I can nest another div inside it smh
return (

View file

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