# mongodb-query-after

> Add an after parameter to your queries

Latest version **0.0.6** (published 2013-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongodb-query-after
pnpm add mongodb-query-after
yarn add mongodb-query-after
bun add mongodb-query-after
```

## 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.6 |
| Published | 2013-10-10 |
| First published | 2013-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jonathan Ong |
| Maintainers | jongleberry |

## Links

- npm: https://www.npmjs.com/package/mongodb-query-after
- Repository: https://github.com/stream-utils/mongodb-query-after
- Issues: https://github.com/stream-utils/mongodb-query-after/issues
- npm.io page: https://npm.io/package/mongodb-query-after

## Dependencies (1)

- [cursor-construct](https://npm.io/package/cursor-construct.md) ~0.0.1

## Recent versions

- 0.0.6 (latest) — 2013-10-10
- 0.0.5 — 2013-09-03
- 0.0.4 — 2013-09-03
- 0.0.3 — 2013-05-21
- 0.0.2 — 2013-05-16
- 0.0.1 — 2013-04-27

## README

# MongoDB Query After [![Build Status](https://travis-ci.org/stream-utils/mongodb-query-after.png)](https://travis-ci.org/stream-utils/mongodb-query-after)

`after` support for queries instead of pagination.
This ticket has been filed in [jira.mongodb.org](https://jira.mongodb.org/browse/SERVER-8468) as a feature as this would be better if done on the database instead of the client.

You should only use this if `after` is actually used,
otherwise just use a regular query.

## API

### `query()`

```js
var query = require('mongodb-query-after')

query(collection, criteria, options).toArray()
```

These are the same arguments as `collection.find()`.
Currently, all fields are required.
The only difference is that there are two additional parameters for `options`:

- `options.after` - Begins returning documents after the document with `{_id: after}`.
- `options.seek` - Begins searching from the top of the query.
  Will stop the query after `seek` documents have been searched,
  regardless whether `limit` documents have been returned.

### `query().stream()`

Returns a stream with only three events:

- `stream.on('error', function (err) {})`
- `stream.on('end', function () {})`,
  also aliased as `close` for ubiquity
- `stream.on('data', function (doc) {})`

### `query().toArray(function (err, docs))`

Equivalent to `collection.find().toArray()`

### `query().each(function (err, doc))`

Equivalent to `collection.find().each()`

## License

The MIT License (MIT)

Copyright (c) 2013 Jonathan Ong me@jongleberry.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

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