@caruuto/api-metadata

2.0.0 • Public • Published

Metadata

Generates pagination metadata for API result sets.

{
  "page": 2,
  "limit": 20,
  "offset": 0,
  "totalCount": 200,
  "totalPages": 10,
  "nextPage": 3,
  "prevPage": 1
}

Installation

$ npm i api-metadata

Usage

The metadata function accepts two arguments:

argument description
options the options that were used to generate the data set
options.page the page number requested
options.limit the number of records requested
options.skip the number of records skipped
count the total number of records in the original data set, before options were applied
const apiMetadata = require('api-metadata')

const options = {
  page: 2,
  limit: 20
}

const metadata = apiMetadata(options, 200)

Readme

Keywords

none

Package Sidebar

Install

npm i @caruuto/api-metadata

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

3.09 kB

Total Files

8

Last publish

Collaborators

  • woogz
  • jimlambie