Skip to content

Commit

Permalink
fix: limit
Browse files Browse the repository at this point in the history
  • Loading branch information
TinsFox committed Nov 15, 2024
1 parent 4b45a95 commit 8a031d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/module/users/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ userRouter.openapi(getUsersRoute, async (c) => {
const allUsers = await dbClientInWorker(c.env.DATABASE_URL)
.select()
.from(users)
.offset((page - 1) * pageSize)
.offset(page * pageSize)
.limit(pageSize)

const totalResult = await dbClientInWorker(c.env.DATABASE_URL).select({ count: count() }).from(users)
const total = Number(totalResult[0].count)
Expand Down
2 changes: 1 addition & 1 deletion src/schema/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const BasePaginateQuerySchema = z.object({
description: 'Page number',
example: 1,
})
.default(1),
.default(0),
pageSize: z.coerce
.number()
.optional()
Expand Down

0 comments on commit 8a031d7

Please sign in to comment.