Drop

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Drop( num, array )
Drop( num, array )
Drop( num, array )
drop( num, array )
Drop( num, array )

Description

The Drop function returns a new array of the same type that contains the remaining elements, after num have been removed from the head of the array. If num is zero or negative, all elements of the array are returned unmodified.

When applied to a Page, the returned page’s before cursor is adjusted to exclude the dropped elements. As special cases:

  • If num is negative, before does not change.

  • Otherwise if all elements from the original page were dropped (including the case where the page was already empty), before is set to same value as the original page’s after.

Parameters

Parameter Type Definition and Requirements

array

Array or Page

The drop operations should be performed on this array.

num

Integer

The number of elements to extract from the beginning of the array.

Returns

A new array of the same type omitting the first num elements.

Examples

The following query creates a new array containing a copy of the last element of the array passed into the function:

try
{
    Value result = await client.Query(
        Drop(2, Arr(1, 2, 3))
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
Arr(LongV(3))
result, err := client.Query(
	f.Drop(2, f.Arr{1, 2, 3}))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[3]
client.query(
  q.Drop(2, [1, 2, 3])
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ 3 ]
result = client.query(
  q.drop(2, [1, 2, 3])
)
print(result)
[ 3 ]
Drop(2, [1, 2, 3])
[ 3 ]
Query metrics:
  •    bytesIn:  31

  •   bytesOut:  16

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 4ms

  •    retries:   0

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!