Prepend

Prepend( elems, base )
Prepend( elems, base )
Prepend( elems, base )
Prepend( elems, base )
prepend( elems, base )
prepend elems, base
Prepend( elems, base )
Prepend( elems, base )

Description

The Prepend function creates a new array that is the result of combining the elems followed by the base array. This function only works with arrays, not with pages.

Parameters

Argument Type Definition and Requirements

base

The base array.

elems

Value or Array

The elements to add to the beginning of the base array.

Returns

A new array containing both elems followed by the array.

Examples

A new array containing the elems array values, (1, 2, 3), followed by the array values, (4, 5, 6).

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "prepend": [ 1, 2, 3 ], "collection": [ 4, 5, 6 ] }'
client.Query(Prepend(Arr(1, 2, 3), Arr(4, 5, 6)));
System.out.println(
        client.query(
                Prepend(
                        Arr(Value(1), Value(2), Value(3)),
                        Arr(Value(4), Value(5), Value(6))
                )
        ).get());
result, _ := client.Query(f.Prepend(f.Arr{1, 2, 3}, f.Arr{4, 5, 6}))

fmt.Println(result)
client.query(Prepend(Arr(1, 2, 3), Arr(4, 5, 6)))
client.query(q.prepend([1, 2, 3], [4, 5, 6]))
$client.query do
  prepend [1, 2, 3], [4, 5, 6]
end
client.query(
    Prepend(elements: Arr(1, 2, 3), to: Arr(4, 5, 6))
)
client.query(
  q.Prepend([1, 2, 3], [4, 5, 6])
)
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": [ 1, 2, 3, 4, 5, 6 ] }
[ 1, 2, 3, 4, 5, 6 ]
[1, 2, 3, 4, 5, 6]
[1 2 3 4 5 6]
[ 1, 2, 3, 4, 5, 6 ]
[ 1, 2, 3, 4, 5, 6 ]
[ 1, 2, 3, 4, 5, 6 ]
[ 1, 2, 3, 4, 5, 6 ]
[ 1, 2, 3, 4, 5, 6 ]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!