Append

Append( elems, base )
Append( elems, base )
Append( elems, base )
Append( elems, base )
append( elems, base )
append elems, base
Append( elems, base )
Append( elems, base )

Description

The Append function creates a new array that is the result of combining the base Array followed by the elems. This is a specialized function, and only works with collections of type Array.

Parameters

Argument Type Definition and Requirements

base

Array

The base array.

elems

Value or Array

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

Returns

A new array containing both the base array followed by the elems.

Examples

The following example creates a new array containing the base array’s values, (1, 2, 3), followed by the elems array’s values, (4, 5, 6).

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

fmt.Println(result)
client.query(Append(Arr(4, 5, 6), Arr(1, 2, 3)))
client.query(q.append([4, 5, 6], [1, 2, 3]))
$client.query do
  append [4, 5, 6], [1, 2, 3]
end
client.query(
    Append(elements: Arr(4, 5, 6), to: Arr(1, 2, 3))
)
client.query(q.Append([4, 5, 6], [1, 2, 3]))
  .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!