# mongoose-query-paginate

> Mongoose Query paginate.

Latest version **2.0.0** (published 2025-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-query-paginate
pnpm add mongoose-query-paginate
yarn add mongoose-query-paginate
bun add mongoose-query-paginate
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-02-13 |
| First published | 2012-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Author | lowol |
| Maintainers | lowol |
| Keywords | mongoose, paginate, pager |

## Links

- npm: https://www.npmjs.com/package/mongoose-query-paginate
- Repository: https://github.com/lowol/mongoose-query-paginate
- Homepage: https://github.com/lowol/mongoose-query-paginate#readme
- Issues: https://github.com/lowol/mongoose-query-paginate/issues
- npm.io page: https://npm.io/package/mongoose-query-paginate

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2025-02-13
- 1.0.3 — 2016-11-07
- 1.0.1 — 2013-11-08
- 1.0.0 — 2013-09-03
- 0.0.4 — 2012-08-31
- 0.0.3 — 2012-08-30
- 0.0.2 — 2012-08-29
- 0.0.1 — 2012-08-06

## README

## mongoose-query-paginate

[Mongoose](https://github.com/LearnBoost/mongoose) Query paginate.

## Installation

    $ npm install mongoose-query-paginate

## Example

    require('mongoose-query-paginate');
    var options = {
      perPage: 10,
      delta  : 3,
      page   : req.query.p
    };
    var query = MyModel.find({deleted: false}).sort('name', 1);
    query.paginate(options, function(err, res) {
      console.log(res); // => res = {
        //  options: options,               // paginate options
        //  results: [Document, ...],       // mongoose results
        //  current: 5,                     // current page number
        //  last: 12,                       // last page number
        //  prev: 4,                        // prev number or null
        //  next: 6,                        // next number or null
        //  pages: [ 2, 3, 4, 5, 6, 7, 8 ], // page numbers
        //  count: 125                      // document count
      //};
    });

## Migration from v1.x to v2

Instead of using callbacks, the paginate method now returns a promise.

So it becomes:

```js
const pager = await query.paginate(options);
```

## License

The MIT License

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