FQL cheat sheet

The page provides a quick reference to all of the Fauna Query Language functions, group by their major functionality:

Array
All

Tests whether all of the provided values are true.

Any

Tests whether any of the provided values are true.

Append

Adds items to end of array.

Count

Counts the items in an array or set.

Difference

Returns an array of items in one array that are missing from additional arrays.

Distinct

Returns an array of the distinct items within multiple arrays.

Drop

Removes items from start of array.

Filter

Fetches specific items from array.

Foreach

Iterates over array items.

Intersection

Returns an array of the items that exist in all arrays.

IsEmpty

Tests whether an array or set is empty.

IsNonEmpty

Tests whether an array or set contains items.

Map

Applies a function to all array items.

Max

Returns the largest value in a list of numbers.

Mean

Returns the average value of the items in an array or set.

Min

Returns the smallest value in a list of numbers.

Prepend

Adds items to start of array.

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.

Sum

Sums the items in an array or set.

Take

Fetches items from start of array.

ToObject

Converts an array to an object.

Union

Returns an array that combines the items in multiple arrays.

Authentication
CreateKey

Create a key.

HasIdentity

Checks whether the current client has credentials.

Identify

Verifies an identity’s credentials.

Identity

Fetches the identity’s auth token.

KeyFromSecret

Retrieves a key based on its secret.

Keys

Retrieves the keys associated with the specified database.

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
ToArray

Converts an object to an array.

ToDate

Converts a value to a date.

ToDouble

Converts a value to a double-precision, floating-point number.

ToInteger

Converts a value to a decimal integer number.

ToMicros

Converts a value to the number of microseconds since Unix epoch.

ToMillis

Converts a value to the number of milliseconds since Unix epoch.

ToNumber

Converts a value to a number.

ToObject

Converts an array to an object.

ToSeconds

Converts a value to the number of seconds since Unix epoch.

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.

Count

Counts the items in an array or set.

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.

Mean

Returns the average value of the items in an array or set.

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.

Sum

Sums the items in an array or set.

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 (now, collection).

Classes

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.

Documents

Returns the set of documents within a collection.

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.

MoveDatabase

Moves a database into another, parent database.

NewId

Generates a unique, numeric id.

Query

Defers execution of a Lambda function.

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.

Select

Retrieves a specific field value from a document.

SelectAll

Retrieves all values for a specific field from a document.

ToArray

Converts an object to an array.

Read
Get

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

SelectAll

Retrieves all values for a specific field from a document.

Set
All

Tests whether all of the provided values are true.

Any

Tests whether any of the provided values are true.

Count

Counts the items in an array or 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.

IsEmpty

Tests whether an array or set is empty.

IsNonEmpty

Tests whether an array or set contains items.

Join

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

Match

Returns the set of items that match search terms.

Max

Returns the largest value in a list of numbers.

Mean

Returns the average value of the items in an array or set.

Min

Returns the smallest value in a list of numbers.

Range

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

Reduce

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

Singleton

Returns a set containing the first item of a set.

Sum

Sums the items in an array or 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.

ContainsStr

Tests whether a string contains a specific string.

ContainsStrRegex

Tests whether a string contains a specific pattern.

EndsWith

Tests whether a string ends with a specific 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.

RegexEscape

Creates a regular expression that matches the input string verbatim.

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.

StartsWith

Tests whether a string starts with a specific string.

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.

Now

Returns a timestamp representing the current transaction time.

Second

Returns the second from a timestamp.

Time

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

TimeAdd

Adds an offset to a provided timestamp/date.

TimeDiff

Returns the difference between two timestamps/dates, in specified units.

TimeSubtract

Subtracts an offset from a provided timestamp/date.

Year

Returns the year from a timestamp.

Type checks
IsArray

Tests whether a value is an array.

IsBoolean

Tests whether a value is a boolean.

IsBytes

Tests whether a value is a group of bytes.

IsCollection

Tests whether a value is a collection ref.

IsCredentials

Tests whether a value is a credentials object.

IsDatabase

Tests whether a value is a database ref.

IsDate

Tests whether a value is a Date.

IsDoc

Tests whether a value is a document.

IsDouble

Tests whether a value is a double-precision, floating point number.

IsFunction

Tests whether a value is a function.

IsIndex

Tests whether a value is an index ref.

IsInteger

Tests whether a value is an integer number.

IsKey

Tests whether a value is a key ref.

IsLambda

Tests whether a value is a Lambda function.

IsNull

Tests whether a value is null.

IsNumber

Tests whether a value is numeric, which includes integers and doubles.

IsObject

Tests whether a value is an object.

IsRef

Tests whether a value is a reference.

IsRole

Tests whether a value is a role.

IsSet

Tests whether a value is a set.

IsString

Tests whether a value is a string.

IsTimestamp

Tests whether a value is a timestamp.

IsToken

Tests whether a value is a token ref.

Write
Create

Create a document in a collection.

CreateClass

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!