Skip to content

A module for Fastify to support Knex's query builder with paginate method

License

Notifications You must be signed in to change notification settings

erwinstone/fastify-knex-paginate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-knex-paginate

A module for Fastify to support Knex's query builder with paginate method

Usage/Examples

import path from 'path'
import fastify from 'fastify'
import fastifyKnex from 'fastify-knex-paginate'

const app = fastify()
app.register(fastifyKnex, {
  client: 'better-sqlite3',
  connection: { filename: path.resolve('./db.sqlite3') },
  useNullAsDefault: true,
})

app.get('/', () => {
  return await app.knex('users').paginate({
    perPage: 5,
    currentPage: req.query.page || 1
  })
})

app.listen({ port: 8000 }, (err, address) => {
  if (err) throw err
  console.log(`server running on ${address}`)
})

API Reference

Read more at

https://github.com/knex/knex

https://github.com/felixmosh/knex-paginate

About

A module for Fastify to support Knex's query builder with paginate method

Resources

License

Stars

Watchers

Forks

Packages

No packages published