Skip to content

Commit

Permalink
fix: convert count(*) result to number
Browse files Browse the repository at this point in the history
  • Loading branch information
tippfehlr committed Apr 13, 2024
1 parent b9bf6ad commit a6e9399
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/modules/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ export async function addActivity(guildID: string, activityName: string) {
.execute();
}

export async function getRowCount(table: TableExpression<DB, keyof DB>): Promise<number> {
return (
await db
.selectFrom(table)
.select(eb => eb.fn.countAll().as('count'))
.executeTakeFirstOrThrow()
).count as number;
export async function getRowCount(table: TableExpression<DB, keyof DB>) {
return Number(
(
await db
.selectFrom(table)
.select(eb => eb.fn.countAll().as('count'))
.executeTakeFirstOrThrow()
).count,
);
}

export async function getUserCount(): Promise<number> {
Expand Down

0 comments on commit a6e9399

Please sign in to comment.