Skip to content

HasLimit

Pipeline implementing the $limit stage.

Inheritors

Properties

context

The context used to generate this pipeline.

Functions

limit

open fun limit(amount: Long): Pipeline<Document>

open fun limit(amount: Int): Pipeline<Document>

Limits the number of elements passed to the next stage to amount.

Using limit with sorted results

Sort results aren't stable with limit: if multiple documents are identical, their relative order is undefined and may change from one execution to the next.

To avoid surprises, include a unique field in your sort, for example _id.

External resources

See also

reinterpret

Changes the type of the returned document, with no type-safety.

toString

abstract override fun toString(): String

JSON representation of this pipeline.

withStage

Creates a new pipeline that expands on the current one by adding stage.

writeTo

@LowLevelApi
abstract fun writeTo(writer: BsonValueWriter)

Writes the entire pipeline into writer.