# sails-pagination

> A sailsjs pagination service

Latest version **0.0.2** (published 2017-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install sails-pagination
pnpm add sails-pagination
yarn add sails-pagination
bun add sails-pagination
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2017-06-06 |
| First published | 2017-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.2.4 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Fian Kurniawan |
| Maintainers | littlefk |
| Keywords | sailsjs, pagination, service |

## Links

- npm: https://www.npmjs.com/package/sails-pagination
- Repository: https://github.com/littlechad/sails-pagination
- Homepage: https://github.com/littlechad/sails-pagination#readme
- Issues: https://github.com/littlechad/sails-pagination/issues
- npm.io page: https://npm.io/package/sails-pagination

## Recent versions

- 0.0.2 (latest) — 2017-06-06
- 0.0.1 — 2017-06-06

## README

# Sails Pagination
A simple sailsjs pagination service

## Installation

  `npm install sails-pagination`

## Usage

assuming that req.query is:

	{
		skip: 0,
		limit: 100,
		sort: 'name ASC'
	}

Then in your sails controller


	const Pagination = require('sails-pagination')

	const buildParams = Pagination.build(req.query)

	Model
    .find(buildParams)
    .then((models) => {
      return [
        models,
        Model.count(buildParams)
      ]
    })
    .spread((models, count) => {
      return Pagination.paginate(count, buildParams, models)
    })
    .then((models) => {
      res.json(models)
    })
    .catch((error) => {
      return res.serverError(error)
    })


## Tests

  `npm test`

## Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

---
_Source: https://npm.io/package/sails-pagination · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
