Carrot reference
...
Fields
Data Types

Sequence

An internal representation of a stream of objects that behaves like a List.

The main difference between a Sequence and a List is that a Sequence performs more efficiently when operating on large sets of data. You can usually treat this like a List.

Properties

Property

Type

Description

first

Object

The first object in the sequence

last

Object

The last object in the sequence

length

Number

The number of entries contained in the Sequence

reversed

Sequence

The sequence, in reverse order

Sequences and Methods

Most commonly, a Sequence is used together with Methods, especially:

  • @filter
  • @limit
  • @sort or @sortDesc

For example:

db.job.find{department:engineering}

Returns a Sequence of Jobs in the Engineering department.

To return the first 5 jobs with more than $100k in Base Comp, sorted in alphabetical order by Title, you could use:

db.job.find{department:engineering}.filter{baseComp > 100000}.sort{title}.limit(5}