From cc75899b01bd033b097287c8b7b443481e1f9a28 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Thu, 10 Aug 2023 17:29:47 +0100 Subject: [PATCH] fix: count without where clause is total users regardless of selection (#10703) --- apps/api/pages/api/users/_get.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/pages/api/users/_get.ts b/apps/api/pages/api/users/_get.ts index 59e09bdeb5..31045caa86 100644 --- a/apps/api/pages/api/users/_get.ts +++ b/apps/api/pages/api/users/_get.ts @@ -40,7 +40,7 @@ export async function getHandler(req: NextApiRequest) { // If user is not ADMIN, return only his data. if (!isAdmin) where.id = userId; const [total, data] = await prisma.$transaction([ - prisma.user.count(), + prisma.user.count({ where }), prisma.user.findMany({ where, take, skip }), ]); const users = schemaUsersReadPublic.parse(data);