Drop
Drop( num, collection )
Drop( num, collection )
Drop( num, collection )
Drop( num, collection )
drop( num, collection )
drop num, collection
Drop( num, collection )
Drop( num, collection )
Description
The Drop
function returns a new collection of the same type that
contains the remaining elements, after num
have been removed from the
head of the collection. If num
is zero or negative, all elements of
the collection are returned unmodified.
When applied to a collection of type 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’safter
.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
Collection |
The drop operations should be performed on this collection. |
|
Integer |
The number of elements to extract from the beginning of the collection. |
Examples
The query below creates a new collection of type Array containing a copy of the last element of the collection passed into the function.
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{ "drop": 2, "collection": [ 1, 2, 3 ] }'
client.Query(Drop(2, Arr(1, 2, 3)));
System.out.println(
client.query(
Drop(Value(2), Arr(Value(1), Value(2), Value(3)))
).get());
result, _ := client.Query(f.Drop(2, f.Arr{1, 2, 3}))
fmt.Println(result)
client.query(Drop(2, Arr(1, 2, 3)))
client.query(q.drop(2, [1, 2, 3]))
$client.query do
drop 2, [1, 2, 3]
end
client.query(Drop(count: 2, from: Arr(1, 2, 3)))
client.query(q.Drop(2, [1, 2, 3]))
.then((ret) => console.log(ret));
HTTP/1.1 200 OK
{ "resource": [ 3 ] }
[ 3 ]
[3]
[3]
[ 3 ]
[ 3 ]
[ 3 ]
[ 3 ]
[ 3 ]
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!