how to get the total matched record count in prisma-binding npm

3.3k views Asked by At

I have been using prisma-binding npm, I don't know how to get the total matched count of the query in order to perform pagination.

I'm using below code to pull record which working fine. Now i want total number of records.

const users = await prisma.query.users(null,`{id, name}`)

Note: By default prisma returns maximum of 3000 records only, but have 9000 records.

1

There are 1 answers

1
Andrew1325 On BEST ANSWER

You need to use the usersConnection query to get a count.

const count = await prisma.query.usersConnection({
  where: {
    // whatever your filter parameters are
  }
}, `{ aggregate { count } }`)

I haven't heard of this maximum returned records, but the usersConnection count is a single record being returned (the count), so that isn't an issue and as you want to do this for pagination I would imagine you would be returning at most 50 records at a time in your query.