Skip to main content

$first

The $first operator returns the first element of an array.

Input

  • A single array value

Output

  • The first element of the array, or null if the array is empty

Examples

Get First Element

{
  "$first": [
    [1, 2, 3, 4, 5]
  ]
}
Result: 1

From Field

{
  "$first": [
    {
      "$input": "items"
    }
  ]
}
Result: The first element of the items field array, or null if the array is empty