简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM