---
title: Sequence
slug: sequence
docTags: 
createdAt: 2021-09-14T17:56:51.000Z
---

An internal representation of a stream of objects that behaves like a [List](docId\:xWH_cUkHj9waqaEfb7H71).

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](docId\:ucI5tCTfVBhonEJ6ZQijg)    | The number of entries contained in the Sequence |
| `reversed`   | [Sequence](docId\:JG4itlQWafzLpArttFo67)  | The sequence, in reverse order                  |

### Sequences and Methods

Most commonly, a Sequence is used together with [Methods](docId\:e-xS-5QFSphnplU0ozZuU), 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}`

