Add an after parameter to your queries

MongoDB Query After

after support for queries instead of pagination. This ticket has been filed in 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.

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}.
  • - 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.

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) {})

Equivalent to collection.find().toArray()

Equivalent to collection.find().each()