Skip to content

Commit

Permalink
Add UsersRepository#coutn
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed Oct 28, 2024
1 parent 26d69a6 commit d8c3e59
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/repositories.server/users.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { User } from "app:entities/user";
import schema from "db:schema";
import { orm } from "@edgefirst-dev/core";
import { eq } from "drizzle-orm";
import { count, eq } from "drizzle-orm";

export class UsersRepository {
async findAll() {
Expand Down Expand Up @@ -54,4 +54,12 @@ export class UsersRepository {
.where(eq(schema.users.id, user.id))
.execute();
}

async count() {
let [result] = await orm()
.select({ count: count() })
.from(schema.users)
.execute();
return result?.count ?? 0;
}
}

0 comments on commit d8c3e59

Please sign in to comment.