MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation.stages • HasLimit • limit
limit¶
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¶
-
HasSkip.skip
Skip over an amount of elements. -
HasSample.sample
Randomly limit the number of elements.
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¶
-
HasSkip.skip
Skip over an amount of elements. -
HasSample.sample
Randomly limit the number of elements.