Skip to content

3.2 Pagination

Lucas Rocha edited this page Feb 11, 2019 · 8 revisions

As described in the usage examples topic, there are two ways to use paging: with skip and with page. The use of page or skip will depend on the use_page configuration used when instantiating the middleware.

1. Pagination With Skip

Example: Returns the first 20 items.

http://localhost:3000/?skip=0&limit=20

Result:

pagination: { 
     "limit": 20,
     "skip": 0 
   } 
}

Example: Returns from the 21st to the 40th items.

http://localhost:3000/?skip=20&limit=20

Result:

pagination: { 
     "limit": 20,
     "skip": 20 
   } 
}

2. Pagination With Page

Example: Returns the 20 first items.

http://localhost:3000/?page=1&limit=20

Result:

pagination: { 
     "limit": 20,
     "page": 1
   } 
}

Example: Returns from the 21st to the 40th items.

http://localhost:3000/?page=2&limit=20

Result:

pagination: { 
     "limit": 20,
     "page": 2
   } 
}
Clone this wiki locally