FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
Take
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Take( num, array )
take( num, array )
Take( num, array )
Take( num, array )
Take( num, array )
Description
The Take
function returns a new array of the same type as the
array
parameter that contains num
elements from the head of the
provided array
. If num
is zero or negative, the resulting array is
empty.
When applied to a Page, the returned page’s "after" cursor is adjusted to only cover the taken elements. As special cases:
-
If
num
is negative,after
is set to the same value as the original page’s "before". -
If all elements from the original page were taken,
after
does not change.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Array or Page |
Extract elements from this Array. |
|
Integer |
The Number of elements to extract from the beginning of
|
Examples
The following query creates a new array containing copies of the first two elements of the array’s argument:
[ 1, 2 ]
[ 1, 2 ]
[1 2]
Arr(LongV(1), LongV(2))
[ 1, 2 ]
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!