Skip to content

Commit 465628d

Browse files
authored
(DOCSP-25293): note behavior when using missing array (#2045) (#2055)
* note behavior when using missing array * Copy review
1 parent 6dd5739 commit 465628d

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

source/reference/operator/aggregation/arrayElemAt.txt

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ Definition
2929
<aggregation-expressions>` that resolves to an array.
3030

3131
The ``<idx>`` expression can be any valid :ref:`expression
32-
<aggregation-expressions>` that resolves to an integer:
33-
34-
- If the ``<idx>`` expression resolves to zero or a positive integer,
35-
:expression:`$arrayElemAt` returns the element at the ``idx``
36-
position, counting from the start of the array.
37-
38-
- If the ``<idx>`` expression resolves to a negative integer,
39-
:expression:`$arrayElemAt` returns the element at the ``idx``
40-
position, counting from the end of the array.
41-
42-
If ``idx`` exceeds the array bounds, :expression:`$arrayElemAt` does
43-
not return a result.
32+
<aggregation-expressions>` that resolves to an integer.
4433

4534
For more information on expressions, see
4635
:ref:`aggregation-expressions`.
4736

4837
Behavior
4938
--------
5039

51-
For more information on expressions, see
52-
:ref:`aggregation-expressions`.
40+
- If the ``<idx>`` expression resolves to zero or a positive integer,
41+
:expression:`$arrayElemAt` returns the element at the ``idx``
42+
position, counting from the start of the array.
43+
44+
- If the ``<idx>`` expression resolves to a negative integer,
45+
:expression:`$arrayElemAt` returns the element at the ``idx``
46+
position, counting from the end of the array.
47+
48+
- If ``idx`` exceeds the array bounds, :expression:`$arrayElemAt` does
49+
not return a result.
50+
51+
- If the ``<array>`` expression resolves to an undefined array,
52+
:expression:`$arrayElemAt` returns ``null``.
5353

5454
.. list-table::
5555
:header-rows: 1
@@ -67,6 +67,9 @@ For more information on expressions, see
6767
* - ``{ $arrayElemAt: [ [ 1, 2, 3 ], 15 ] }``
6868
-
6969

70+
* - ``{ $arrayElemAt: [ "$undefinedField", 0 ] }``
71+
- ``null``
72+
7073
Example
7174
-------
7275

0 commit comments

Comments
 (0)