FQL cheat sheet

This page provides a quick reference of FQL properties and methods, grouped by functionality.

Array
Array.sequence()

Create an ordered Array of Integers, given start and end values.

array.length

Get the number of elements in an Array.

array.aggregate()

Aggregate all elements in an Array.

array.any()

Test if any Array element matches a predicate.

array.append()

Append an element to an Array.

array.at()

Get the Array element at a provided index.

array.concat()

Concatenate two Arrays.

array.distinct()

Get unique elements in an Array.

array.drop()

Drop the first N elements of an Array.

array.entries()

Add the index as a key to each element of an Array.

array.every()

Test if every Array element matches a predicate.

array.filter()

Create an Array of elements filtered by a predicate.

array.first()

Get the first element of an Array.

array.firstWhere()

Get the first Array element that matches a predicate.

array.flatMap()

Apply a function to each Array element and flatten the resulting Array by one level.

array.flatten()

Flatten Array elements by one level.

array.fold()

Reduce the Array to a single, accumulated value by applying a function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value.

array.foldRight()

Reduce the Array to a single, accumulated value by applying a function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value.

array.forEach()

Run a function on each Array element. Can perform writes.

array.includes()

Test if the Array includes a provided element.

array.indexOf()

Get the index of the first Array element that matches a provided value.

array.indexWhere()

Get the index of the first Array element that matches a predicate.

array.isEmpty()

Test if an Array is empty.

array.last()

Get the last element of an Array.

array.lastIndexOf()

Get the index of the last Array element that matches a provided value.

array.lastIndexWhere()

Get the index of the last Array element that matches a predicate.

array.lastWhere()

Get the last Array element that matches a predicate.

array.map()

Apply a function to each Array element. Can’t perform writes.

array.nonEmpty()

Test if an Array is not empty.

array.order()

Sort an Array's elements.

array.prepend()

Prepend an element to an Array.

array.reduce()

Reduce an Array to a single, accumulated value by applying a function to each element. Iterates through elements from left to right. Uses the first element as the initial value.

array.reduceRight()

Reduce an Array to a single, accumulated value by applying a function to each element. Iterates through elements from right to left. Uses the first element as the initial value.

array.reverse()

Reverse the order of an Array's elements.

array.slice()

Copy Array elements to another Array, given element indexes.

array.take()

Get the first N elements of an Array.

array.toSet()

Convert an Array to a Set.

array.toString()

Convert an Array to a String.

array.where()

Get the Array elements that match a predicate.

Collection
collection.definition

Get or update a collection’s definition, represented as a Collection document.

Collection()

Get a Collection by name.

Collection.all()

Get a Set of all Collections.

Collection.byName()

Get a Collection by name.

Collection.create()

Create a Collection.

Collection.firstWhere()

Get the first Collection that matches a predicate.

Collection.toString()

Get Collection as a String.

Collection.where()

Get a Set of Collections that match a predicate.

collection.all()

Get a Set of all documents in a Collection.

collection.byId()

Get a Collection document by its ID.

collection.create()

Create a Collection document.

collection.delete()

Delete a Collection.

collection.exists()

Test if a Collection exists.

collection.firstWhere()

Get the first Collection document that matches a predicate.

collection.indexName()

Call an index to get a Set of matching Collection documents.

collection.where()

Get a Set of Collection documents that match a predicate.

Credential
Credential.all()

Get all credentials.

Credential.byDocument()

Get a credential by its identity document.

Credential.byId()

Get a credential by ID.

Credential.create()

Create a credential by associated an identity document with a password.

Credential.firstWhere()

Get the first credential that matches a predicate.

Credential.toString()

Get Credential as a String.

Credential.where()

Get a Set of credentials that match a predicate.

credential.delete()

Delete a credential.

credential.exists()

Test if a credential exists.

credential.login()

Create a token for a provided credential and its password.

credential.replace()

Replace a credential.

credential.update()

Update a credential.

credential.verify()

Test whether a provided password is valid for a credential.

Database
Database.all()

Get all child databases.

Database.byName()

Get a child database by name.

Database.create()

Create a child database.

Database.firstWhere()

Get the first child database that matches a predicate.

Database.toString()

Get Database as a String.

Database.where()

Get a Set of child databases that match a predicate.

database.delete()

Delete a child database.

database.exists()

Test if a child database exists.

database.replace()

Replace a child database's metadata and settings.

database.update()

Update a child database's metadata and settings.

Date
dayOfMonth

Get a Date's day of the month.

dayOfWeek

Get a Date's day of the week.

dayOfYear

Get a Date's day of the year.

month

Get a Date's month.

year

Get a Date's year.

Date()

Create a Date from a String.

Date.fromString()

Create a Date from a String.

Date.today()

Get the current UTC day as a Date.

date.add()

Add a number of days to a Date.

date.difference()

Get the number of days between two Dates.

date.subtract()

Subtract a number of days to a Date.

date.toString()

Convert a Date to a String.

Function
function.definition

Get or update a UDF’s definition, represented as a Function document.

Function()

Get a user-defined function (UDF) by name.

Function.all()

Get all UDFs.

Function.byName()

Get a UDF by name.

Function.create()

Create a UDF.

Function.firstWhere()

Get the first UDF that matches a predicate.

Function.toString()

Get Function as a String.

Function.where()

Get a Set of UDFs that match a predicate.

function.delete()

Delete a UDF.

function.exists()

Test if a UDF exists.

function.replace()

Replace a UDF.

function.update()

Update a UDF.

Global functions
abort()

Terminate the current query with an error.

dbg()

Output a message in the query response and return the message.

ID()

Convert a 64-bit integer to a document ID.

log()

Output a message in the query response.

newId()

Generate a document ID.

Key
Key.all()

Get all keys.

Key.byId()

Get a key by ID.

Key.create()

Create a key.

Key.firstWhere()

Get the first key that matches a predicate.

Key.toString()

Get Key as a String.

Key.where()

Get a Set of keys that match a predicate.

key.delete()

Delete a key.

key.exists()

Test if a key exists.

key.replace()

Replace a key.

key.update()

Update a key.

Math
Math.E

Get a Number representing e (Euler’s number).

Math.Infinity

Get a Number representing infinity.

Math.NaN

Get a Number representing a floating point number that is undefined or can’t be represented.

Math.PI

Get a Number representing π (pi).

Math.abs()

Get the absolute value of a Number.

Math.acos()

Get the inverse cosine in radians of a Number.

Math.asin()

Get the inverse sine in radians of a Number.

Math.atan()

Get the inverse tangent in radians of a Number.

Math.ceil()

Round up a Number.

Math.cos()

Get the cosine of a Number in radians.

Math.cosh()

Get the hyperbolic cosine of a Number.

Math.degrees()

Convert radians to degrees.

Math.exp()

Get the value of raised to the power of a Number.

Math.floor()

Round down a Number.

Math.hypot()

Get the hypotenuse of a right triangle.

Math.log()

Get the natural logarithm, base e, of a Number.

Math.log10()

Get the base 10 logarithm of a Number.

Math.max()

Get the larger of two Numbers.

Math.mean()

Get the mean of an Array of Numbers.

Math.min()

Get the smaller of two Numbers.

Math.pow()

Get the value of a base raised to a power.

Math.radians()

Convert the value of a Number in degrees to radians.

Math.round()

Get the value of a Number rounded to the nearest Int.

Math.sign()

Get the sign of a Number.

Math.sin()

Get the sine of a Number in radians.

Math.sinh()

Get the hyperbolic sine of a Number.

Math.sqrt()

Get the square root of a Number.

Math.sum()

Get the sum of an Array or Set of Numbers.

Math.tan()

Get the tangent of a Number in radians.

Math.tanh()

Get the hyperbolic tangent of a Number.

Math.trunc()

Truncate a Number to a given precision.

Object
Object.assign()

Copies properties from a source Object to a destination Object.

Object.entries()

Convert an Object to an Array of key-value pairs.

Object.fromEntries()

Convert an Array of key-value pairs to an Object.

Object.hasPath()

Test if an Object has a property.

Object.keys()

Get an Object's top-level property keys as an Array.

Object.select()

Get an Object property’s value by its path.

Object.toString()

Convert an Object to a String.

Object.values()

Get an Object's property values as an Array.

Query
Query.identity()

Get the current identity document for a query’s authentication token.

Query.isEnvProtected()

Test if the database is in protected mode.

Query.isEnvTypechecked()

Test if the database has typechecking enabled.

Query.token()

Get the query’s authentication token document or JWT payload.

Schema
FQL.Schema.defForIdentifier()

Get the FQL definition for a user-defined collection or user-defined function (UDF) by its ID.

Set
Set.paginate()

Gets a page of paginated results using an after cursor.

Set.sequence()

Create an ordered Set of Integers, given start and end values.

Set.single()

Creates a Set containing a single provided element.

set.aggregate()

Aggregate all elements in a Set.

set.any()

Test if any Set element matches a predicate.

set.changesOn()

Creates a stream that tracks changes to specified document fields in a Set.

set.concat()

Concatenate two Sets.

set.count()

Get the number of elements in a Set.

set.distinct()

Get unique elements in a Set.

set.drop()

Drop the first N elements of a Set.

set.every()

Test if every Set element matches a predicate.

set.first()

Get the first element of a Set.

set.firstWhere()

Get the first Set element that matches a predicate.

set.flatMap()

Apply a function to each Set element and flatten the resulting Set by one level.

set.fold()

Reduce the Set to a single, accumulated value by applying a function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value.

set.foldRight()

Reduce the Set to a single, accumulated value by applying a function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value.

set.forEach()

Run a function on each Set element. Can perform writes.

set.includes()

Test if the Set includes a provided element.

set.isEmpty()

Test if a Set is empty.

set.last()

Get the last element of a Set.

set.lastWhere()

Get the last Set element that matches a predicate.

set.map()

Apply a function to each Set element. Can’t perform writes.

set.nonEmpty()

Test if a Set is not empty.

set.order()

Sort a Set's elements.

set.pageSize()

Sets the maximum elements per page in paginated results.

set.paginate()

Returns the calling Set as an Object with pagination.

set.reduce()

Reduce a Set to a single, accumulated value by applying a function to each element. Iterates through elements from left to right. Uses the first element as the initial value.

set.reduceRight()

Reduce a Set to a single, accumulated value by applying a function to each element. Iterates through elements from right to left. Uses the first element as the initial value.

set.reverse()

Reverse the order of a Set's elements.

set.take()

Get the first N elements of a Set.

set.toArray()

Convert a Set to an Array.

set.toStream()

Creates a stream that tracks changes to documents in a Set.

set.toString()

Returns the string [set].

set.where()

Get the Set elements that match a predicate.

String
string.length

Get the length of a String.

string.at()

Get the character located at a provided index of a String.

string.casefold()

Aggressively convert a String to lower case.

string.concat()

Concatenate two Strings.

string.endsWith()

Test if a String ends with the provided substring.

string.includes()

Test if a substring exists in a String.

string.includesRegex()

Test if a String includes a substring that matches a provided regular expression.

string.indexOf()

Get the index of a substring in a String.

string.indexOfRegex()

Get the index of a substring that matches a provided regular expression.

string.insert()

Insert a substring at a provided index.

string.lastIndexOf()

Get the last occurrence of a substring in a String.

string.matches()

Get substrings that match a provided substring or regular expression.

string.matchIndexes()

Get the indexes of substrings that match a provided substring or regular expression.

string.parseDouble()

Convert a String to a Double.

string.parseInt()

Convert a String to a Int.

string.parseLong()

Convert a String to a Long.

string.parseNumber()

Convert a String to a Number.

string.replace()

Replace the first occurrence of a substring.

string.replaceAll()

Replace all occurrences of a substring.

string.replaceAllRegex()

Replace all occurrences of a substring that matches a regular expression.

string.replaceRegex()

Replace a provided number of occurrences of a substring that matches a regular expression.

string.slice()

Get the substring between two indexes of a String.

string.split()

Split a String at a provided delimiter.

string.splitAt()

Split a String at a provided index.

string.splitRegex()

Split a String using a regular expression as a delimiter.

string.startsWith()

Test if a String starts with a provided substring.

string.toLowerCase()

Convert a String to lower case.

string.toString()

Convert a value to a String.

string.toUpperCase()

Convert a String to upper case.

Time
dayOfMonth

Get a Time's day of the month.

dayOfWeek

Get a Time's day of the week.

dayOfYear

Get a Time's day of the year.

hour

Get a Time's hour.

minute

Get a Time's minute.

month

Get a Time's month.

second

Get a Time's second.

year

Get a Time's year.

Time()

Create a Time from an ISO 8601 time String.

Time.epoch()

Create a Time from a Unix epoch timestamp.

Time.fromString()

Create a Time from an ISO 8601 time String.

Time.now()

Get the current UTC time as a Time.

time.add()

Add a time interval to a Time.

time.difference()

Get the difference between two Times.

time.subtract()

Subtract a time interval to a Time.

time.toMicros()

Convert a Time to Unix epoch timestamp in microseconds.

time.toMillis()

Convert a Time to Unix epoch timestamp in milliseconds.

time.toSeconds()

Convert a Time to Unix epoch timestamp in seconds.

time.toString()

Convert a Time to an ISO 8601 time String.

Token
Token.all()

Get all tokens.

Token.byDocument()

Get a token by its identity document.

Token.byId()

Get a token by ID.

Token.create()

Create a token without a credential.

Token.firstWhere()

Get the first token that matches a predicate.

Token.toString()

Get Token as a String.

Token.where()

Get a Set of tokens that match a predicate.

token.delete()

Delete a token.

token.exists()

Test if a token exists.

token.replace()

Replace a token.

token.update()

Update a token.

Transaction Time
TransactionTime()

Get a query’s transaction commit time.

TransactionTime.toString()

Get [transaction time] as a String.

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!