resource-router-middleware icon indicating copy to clipboard operation
resource-router-middleware copied to clipboard

Pagination params

Open duard opened this issue 8 years ago • 1 comments

How can I load only some records ?

examples : http://localhost:4040/api/ibge/2 http://localhost:4040/api/ibge?limit=10&page=3

thanks

duard avatar Oct 25 '17 14:10 duard

i ended up doing sth like this for ?limit=10&offset=10 with max limit 500 and defaults 100 & 0 respectively while using rethinkdb as db

  index({ query }, res) {
    var limit = parseInt(query.limit) || 100
    limit = limit > 500 ? 500 : limit
    var offset = parseInt(query.offset) || 0
    r.db('database').table('table').slice(offset, offset + limit).run(db, toRes(res))
  },

okwme avatar May 04 '18 15:05 okwme