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:

Array
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.

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 documents 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.

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 a document 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.

ClassDeprecated

Returns the ref for a class (now, collection).

ClassesDeprecated

Returns an array of refs of all classes (now, collections).

Collection

Returns the ref for a collection.

Collections

Returns an array of refs of all collections.

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.

Ref

Returns the reference to a specific document in a collection.

Role

Returns the ref for a user-defined role.

Roles

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

Object
Merge

Merge two objects into one, with an optional resolver lambda.

Read
Get

Retrieves the document for the specified reference.

KeyFromSecret

Retrieves a key based on its secret.

Paginate

Returns a subset of query results.

Reduce

Reduce an array or set to a result via a lambda function.

Select

Retrieves a specific field value from a document.

SelectAll

Retrieves all values for a specific field from a document.

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.

Events

Returns the set of events describing the history of a set/ref.

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.

Range

Returns a subset of a set, in the specified range.

Singleton

Returns a set containing the first item of a set.

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.

Format

Formats arguments as a string according to a string of format specifiers.

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.

DayOfMonth

Returns the day of the month from a timestamp.

DayOfWeek

Returns the day of the week from a timestamp.

DayOfYear

Returns the day of the year from a timestamp.

Epoch

Creates a timestamp from an offset since 1970-01-01 in seconds, milliseconds, microseconds, or nanoseconds.

Hour

Returns the hour from a timestamp.

Minute

Returns the minute from a timestamp.

Month

Returns the month from a timestamp.

Second

Returns the second from a timestamp.

Time

Converts now, or an ISO-8601 string, into a timestamp.

Year

Returns the year from a timestamp.

Write
Create

Create a document in a collection.

CreateClassDeprecated

Create a class (now, collection).

CreateCollection

Create a collection.

CreateDatabase

Create a database.

CreateFunction

Create a user-defined function.

CreateIndex

Create an index.

CreateKey

Create a key.

CreateRole

Create a user-defined role.

Delete

Remove a document, key, index, collection, or database.

Insert

Add an event to a document’s history.

Remove

Remove an event from a document’s history.

Replace

Replace an document with a new document.

Update

Revise specific fields within a document.

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!