Skip to content

Pagination

Christoph Herrmann edited this page Oct 17, 2019 · 3 revisions

Because of pagination is a common use case there is also a pagination shorthand:

const page = 5
const pageSize = 15

const result = await sql.query(sql`
  SELECT * FROM users ${sql.pagination(page, { pageSize })}
`)

// text: SELECT * FROM users LIMIT 15 OFFSET 75
// values: []

The default pageSize 10 can be changed by setting sql.defaultPageSize.

Clone this wiki locally