The Fauna service will be ending on May 30, 2025.

For more information on the service wind down, see our announcement and the Fauna Service End-of-Life FAQ.

ToInteger

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

Copied!
ToInteger( value )

Description

The ToInteger function converts a value to a numeric integer, if possible.

Attempting to convert a value to a number which has no numeric representation results in an "invalid argument" error.

Parameters

Parameter Type Definition and Requirements

value

Any

The value to attempt to convert to an Integer.

Returns

An Integer that corresponds to value.

Examples

The following query uses ToInteger multiple times to demonstrate how the function converts various kinds of values into integers:

Copied!
[
  ToInteger(1234.5678),
  ToInteger(1234),
  ToInteger('123'),
]
[ 1234, 1234, 123 ]
Query metrics:
  •    bytesIn:  67

  •   bytesOut:  28

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 5ms

  •    retries:   0

\