From cbb7b8192cf06f9ca2627829a21fc8731f247a94 Mon Sep 17 00:00:00 2001 From: fa-salu Date: Thu, 28 Nov 2024 10:37:23 +0530 Subject: [PATCH] pagination feature update --- src/controllers/admin/adminController.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/controllers/admin/adminController.ts b/src/controllers/admin/adminController.ts index f5256bc..4f48e3d 100644 --- a/src/controllers/admin/adminController.ts +++ b/src/controllers/admin/adminController.ts @@ -58,7 +58,7 @@ export const getAllWorkspacesWithSpaces = async (req: CustomRequest, res: Respon throw new CustomError("Unauthorized access", 401); } - const { page = 1, limit = 10 } = req.query; + const { page = 1, limit = 12 } = req.query; const skip = (Number(page) - 1) * Number(limit); @@ -79,14 +79,13 @@ export const getAllWorkspacesWithSpaces = async (req: CustomRequest, res: Respon }, ]); - const total = workspacesWithSpaces[0]?.totalCount[0]?.count || 0; + const total = await Workspace.countDocuments(); res.status(200).json( new StandardResponse("Workspaces with spaces retrieved successfully", { data: workspacesWithSpaces[0]?.data || [], total, page: Number(page), - limit: Number(limit), }), ); };