Carrot reference
Methods

.limit()

Returns a specified number of results from a List or Sequence .

Syntax

.limit(number)

Returns

List or Sequence - limited to the number of results.

  • number - the number of results to return.

Return type: List

Examples

volunteers.limit(4) returns the first 4 people from the volunteers list.

db.job.find{dept:engineering}.limit(3) returns the first three jobs found in the Engineering department.

findHistoryValues( { checkinScore } ).limit(3).mean() returns the average of the first 3 values of the checkinScore field.