FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard.

For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions.

Prepend

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

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

Parameter Type Definition and Requirements

base

Array

The base Array.

elems

Value or Array

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

Returns

A new Array containing the elems followed by the base Array.

Examples

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

client.query(
  q.Prepend([1, 2, 3], [4, 5, 6])
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ 1, 2, 3, 4, 5, 6 ]
result = client.query(
  q.prepend([1, 2, 3], [4, 5, 6])
)
print(result)
[1, 2, 3, 4, 5, 6]
result, err := client.Query(
	f.Prepend(f.Arr{1, 2, 3}, f.Arr{4, 5, 6}))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[1 2 3 4 5 6]
try
{
    Value result = await client.Query(
        Prepend(Arr(1, 2, 3), Arr(4, 5, 6))
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
Arr(LongV(1), LongV(2), LongV(3), LongV(4), LongV(5), LongV(6))
System.out.println(
    client.query(
        Prepend(
            Arr(Value(1), Value(2), Value(3)),
            Arr(Value(4), Value(5), Value(6))
        )
    ).get());
[1, 2, 3, 4, 5, 6]
Prepend([1, 2, 3], [4, 5, 6])
[ 1, 2, 3, 4, 5, 6 ]
Query metrics:
  •    bytesIn:  40

  •   bytesOut:  26

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 2ms

  •    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!