array.flatMap()
This method operates on an array. You typically fetch documents from a collection as a set, not an array. For the equivalent set method, see set instance methods. For differences between sets and arrays, see Sets vs. arrays. |
Description
The flatMap()
method creates an Array by invoking function on
each element of the calling array and flattening the
resulting array one level. The Array elements are passed as a
parameter to function, sequentially.
The calling array isn’t changed.
Array iteration methods
FQL provides several methods for iterating over an array.
array.forEach()
and
array.map()
are similar but used
for different purposes:
Method | Primary use | Notes |
---|---|---|
Perform in-place writes on array elements. |
Doesn’t return a value. |
|
Return a new array with projected or transformed elements. |
Can’t perform writes. |
|
Similar to |
Can’t perform writes. |
Parameters
Return value
Type | Description |
---|---|
Array with the results of calling function on each element of the calling array. The resulting array is flattened by one level. |
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!