Skip to content

How to get total documents count along with pagination #3087

Answered by ryands17
aakashkag asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @aakashkag 👋
You could perform this with a transaction here and return the result as per your schema:

await prisma.transaction([
    prisma.user.count(),
    prisma.user.findMany({
      take: 5,
      cursor: {
        id: 5,
      },
    }),
  ])

Replies: 17 comments 30 replies

Comment options

You must be logged in to vote
14 replies
@ChristianRich
Comment options

@zaverden
Comment options

@transitive-bullshit
Comment options

@motdde
Comment options

@benbatuu
Comment options

Answer selected by aakashkag
Comment options

You must be logged in to vote
2 replies
@cesarvspr
Comment options

@andreasvh-conceto
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bsplosion
Comment options

Comment options

You must be logged in to vote
1 reply
@vsinghipcium
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@eavonius
Comment options

@bsplosion
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Toshiro00
Comment options

Comment options

You must be logged in to vote
1 reply
@zaverden
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@kyle-turn2
Comment options

@kyle-turn2
Comment options

Comment options

You must be logged in to vote
1 reply
@anhnch
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@ndom91
Comment options

@ndom91
Comment options

@zwhitchcox
Comment options

@ndom91
Comment options

@MkDierz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet