Functions

The section provides a reference for all of the commands in FQL, the Fauna Query Language. The reference is organized by major functionality groups:

Authentication
HasIdentity

Checks whether the current client has credentials.

Identify

Verifies an identity’s credentials.

Identity

Fetches the identity’s auth token.

Login

Creates an auth token for an identity.

Logout

Logs out of the current (or all) sessions.

Basic
At

Retrieves instances at or before a timestamp.

Call

Executes a user-defined function.

Do

Executes expressions in order.

If

Evaluates an expression.

Lambda

Executes an anonymous function.

Let

Defines a variable’s value.

Var

Uses a variable’s value.

Collection
Append

Adds items to end of array.

Drop

Removes items from start of array.

Filter

Fetches specific items from array.

Foreach

Iterates over array items.

IsEmpty

Tests whether array is empty.

IsNonEmpty

Tests whether an array contains items.

Map

Applies a function to all array items.

Prepend

Adds items to start of array.

Take

Fetches items from start of array.

Conversion
ToDate

Converts a value to a date.

ToNumber

Converts a value to a number.

ToString

Converts a value to a string.

ToTime

Converts a value to a timestamp.

Logical
And

Returns true if all values are true.

Contains

Returns true when an object path points to an object’s value.

Equals

Returns true of all values are equivalent.

Exists

Returns true if an instance has an event at a specific time.

GT

Returns true if each value is greater than all following values.

GTE

Returns true if each value is greater than, or equal to, all following values.

LT

Returns true if each value is less than all following values.

LTE

Returns true if each value is less than, or equal to, all following values.

Not

Returns the opposite of a boolean expression.

Or

Returns true if any value is true.

Math
Abs

Returns the absolute value of a number.

Acos

Returns the arc cosine of a number.

Add

Returns the sum of one or more numbers.

Asin

Returns the arc sine of a number.

Atan

Returns the arc tangent of a number.

BitAnd

Returns the bitwise AND of one or more numbers.

BitNot

Returns the bitwise AND of one or more numbers.

BitOr

Returns the bitwise OR of one or more numbers.

BitXor

Returns the bitwise exclusive-OR of one or more numbers.

Ceil

Returns an integer that is greater than, or equal to, a number.

Cos

Returns the cosine of a number.

Cosh

Returns the hyperbolic cosine of a number.

Degrees

Converts a number from radians to degrees.

Divide

Returns the quotient of two or more numbers.

Exp

Returns e raised to the power of a number.

Floor

Returns an integer that is less than, or equal to, a number.

Hypot

Returns the length of a hypotenuse of a right triangle, given the lengths of the other two sides.

Ln

Returns the natural logarithm (base e) of a number.

Log

Returns the natural logarithm (base 10) of a number.

Max

Returns the largest value in a list of numbers.

Min

Returns the smallest value in a list of numbers.

Modulo

Returns the remainder after dividing a list of numbers.

Multiply

Returns the product of a list of numbers.

Pow

Returns the value of a number raised to an exponent.

Radians

Converts a number from degrees to radians.

Round

Returns the integer that is closest to a number.

Sign

Returns 1, 0, or -1 to indicate the sign of a number.

Sin

Returns the sine of a number.

Sinh

Returns the hyperbolic sine of a number.

Sqrt

Returns the square root of a number.

Subtract

Returns the difference of a list of numbers.

Tan

Returns the tangent of a number.

Tanh

Returns the hyperbolic tangent of a number.

Trunc

Truncates a number to the specified decimal places.

Miscellaneous
Abort

Terminates the current transaction.

Class

Returns the ref for a class.

Classes

Returns an array of refs of all classes.

Database

Returns the ref for a database.

Databases

Returns an array of refs of all databases.

Function

Returns the ref for a user-defined function.

Functions

Returns an array of refs of all user-defined functions.

Index

Returns the ref for an index.

Indexes

Returns an array of refs for all indexes.

NewId

Generates a unique, numeric id.

Read
Get

Retrieves an instance for the specified reference.

KeyFromSecret

Retrieves a key based on its secret.

Paginate

Returns a subset of query results.

Select

Retrieves a specific field value from an instance.

SelectAll

Retrieves all values for a specific field from an instance.

Set
Difference

Returns the set of items in one set that are missing from additional sets.

Distinct

Returns the set of distinct items within a set.

Intersection

Returns the set of items that exist in all sets.

Join

Combines the items in a set with set’s indexed values.

Match

Returns the set of items that match search terms.

Union

Returns a set that combines the items in multiple sets.

String
CaseFold

Converts a string into a case-normalized string.

Concat

Combines a list of strings into a single string.

FindStr

Searches for a string within a string.

FindStrRegex

Searches for a regex pattern within a string.

LTrim

Removes all whitespace from the start of a string.

Length

Returns the length in codepoints of a string.

LowerCase

Converts a string to all lowercase.

RTrim

Removes all whitespace from the end of a string.

Repeat

Creates a new string by repeating a string multiple times.

ReplaceStr

Replaces a portion of a string with another string.

ReplaceStrRegex

Replaces a pattern in a string with another string.

Space

Creates a whitespace string of the specified size.

SubString

Returns a portion of a string.

TitleCase

Converts a string to use TitleCase.

Trim

Removes all whitespace from the start and end of a string.

UpperCase

Converts a string to all uppercase.

Time and Date
Date

Converts an ISO-8601 string into a Date.

Epoch

Creates a timestamp from the number of seconds since 1970-01-01.

Time

Converts and ISO-8601 string into a timestamp.

Write
Create

Create an instance in a class.

CreateClass

Create a class.

CreateDatabase

Create a database.

CreateFunction

Create a user-defined function.

CreateIndex

Create an index.

CreateKey

Create a key.

Delete

Remove an instance, key, index, class, or database.

Insert

Add an event to an instance’s history.

Remove

Remove an event from an instance’s history.

Replace

Replace an instance with a new instance.

Update

Revise specific fields within an instance.