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

For more details, review the migration guide. Contact support@fauna.com with any questions.

Repeat

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

Repeat( value, [ number ] )
repeat( value, [ number ] )
Repeat( value, [ number ] )
Repeat( value, [ number ] )
Repeat( value, [ number ] )

Description

The Repeat function returns a string consisting of the value string repeated number times.

Parameters

Parameter Type Definition and Requirements

value

String

The String to repeat.

number

Number

Optional - The Number of times that the value string should be repeated. The default is 2.

Returns

A String with the value string repeated number times.

Examples

The following query executes an array of independent repeat operations and returns the results in an array. The result array position matches the execution array position. The individual operations are:

  1. The string Yes is concatenated with itself. The result string YesYes is placed in the top position of the result array.

  2. The string Yes! , containing a trailing space, is repeated 3 times. The result string Yes! Yes! Yes! is placed in the second position of the result array.

  3. The string = is repeated 10 times. The result string ========== is placed in the third position of the result array.

client.query(
  [
    q.Repeat('Yes'),
    q.Repeat('Yes! ', 3),
    q.Repeat('=', 10),
  ]
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ 'YesYes', 'Yes! Yes! Yes! ', '==========' ]
result = client.query(
  [
    q.repeat("Yes"),
    q.repeat("Yes! ", 3),
    q.repeat("=", 10),
  ]
)
print(result)
['YesYes', 'Yes! Yes! Yes! ', '==========']
result, err := client.Query(
	f.Arr{
		f.Repeat("Yes"),
		f.Repeat("Yes! ", f.Number(3)),
		f.Repeat("=", f.Number(10)),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[YesYes Yes! Yes! Yes!  ==========]
try
{
    Value result = await client.Query(
        Arr(
            Repeat("Yes"),
            Repeat("Yes! ", 3),
            Repeat("=", 10)
        )
    );

    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
Arr(StringV(YesYes), StringV(Yes! Yes! Yes! ), StringV(==========))
[
  Repeat('Yes'),
  Repeat('Yes! ', 3),
  Repeat('=', 10),
]
[ 'YesYes', 'Yes! Yes! Yes! ', '==========' ]
Query metrics:
  •    bytesIn:  75

  •   bytesOut:  54

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