# mongoose-cursorbatched

> A mongoose plugin that allows iterations over batches with cursor.

Latest version **1.0.4** (published 2021-07-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongoose-cursorbatched
pnpm add mongoose-cursorbatched
yarn add mongoose-cursorbatched
bun add mongoose-cursorbatched
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-07-06 |
| First published | 2021-07-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alejandro Soto |
| Maintainers | asotoglez |
| Keywords | mongoose, plugin, cursor, mongo, mongodb, batch |

## Links

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

## 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
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 1.0.4 (latest) — 2021-07-06
- 1.0.3 — 2021-07-06
- 1.0.2 — 2021-07-06
- 1.0.1 — 2021-07-05
- 1.0.0 — 2021-07-05

## README

# mongoose-cursorbatched
A mongoose plugin that allows iterations over batches with cursor.
## Installation
```shell
$ npm i --save mongoose-cursorbatched
```

## Parameters
```
  batchSize: Number of records per batch (default: 20)
```

## How to use
```js
const mongoose = require('mongoose');
const cursorbatched = require('mongoose-cursorbatched');
mongoose.plugin(cursorbatched);

mongoose
  .connect(MONGODB_CONNECTION_STRING, {
    appname: 'test-db',
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })
  .then(async () => {

    function timeout(ms) {
      return new Promise((resolve) => setTimeout(resolve, ms));
    }

    // Use it like this
    const cursor = await User.find({}).cursorBatched({ batchSize: 5 });

    for await (const batch of cursor) {
      // Here you can run your process with the data...
      // Example:
      console.log('batch', batch);
      await timeout(5000);
    }
  });
```
## Example result
![image](https://user-images.githubusercontent.com/24250413/124524518-6524af00-ddc9-11eb-82ec-ce5e96c9413d.png)

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