Module: query

This module contains functions used to construct FaunaDB Queries.

See the FaunaDB Query API Documentation for per-function documentation.

Source:

Methods

(inner) Abort(msg) → {Expr}

See the docs.

Parameters:
Name Type Description
msg module:query~ExprArg

The message to send back to the client.

Source:
Returns:
Type
Expr

(inner) Abs(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A numbers to provide the absolute value.

Source:
Returns:
Type
Expr

(inner) AccessProvider(name) → {Expr}

Parameters:
Name Type Description
name module:query~ExprArg

A string representing an AccessProvider's name

Source:
Returns:
Type
Expr

(inner) AccessProviders(scope) → {Expr}

Parameters:
Name Type Description
scope module:query~ExprArg

The Ref of the database set's scope.

Source:
Returns:
Type
Expr

(inner) Acos(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The arc cosine of the number

Source:
Returns:
Type
Expr

(inner) Add(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to sum together.

Source:
Returns:
Type
Expr

(inner) All(collection) → {Expr}

Evaluates to true if all elements of the collection are true.

Parameters:
Name Type Description
collection array

collection the collection

Source:
See:
Returns:
Type
Expr

(inner) And(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection to compute the conjunction of.

Source:
Returns:
Type
Expr

(inner) Any(collection) → {Expr}

Evaluates to true if any element of the collection is true.

Parameters:
Name Type Description
collection array

collection the collection

Source:
See:
Returns:
Type
Expr

(inner) Append(elements, collection) → {Expr}

See the docs.

Parameters:
Name Type Description
elements module:query~ExprArg

An expression resulting in a collection of elements to append to the given collection.

collection module:query~ExprArg

An expression resulting in a collection.

Source:
Returns:
Type
Expr

(inner) Asin(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The arc sine of the number

Source:
Returns:
Type
Expr

(inner) At(timestamp, expr) → {Expr}

See the docs.

Parameters:
Name Type Description
timestamp module:query~ExprArg

An Expr that will evaluate to a Time.

expr module:query~ExprArg

The Expr to run at the given snapshot time.

Source:
Returns:
Type
Expr

(inner) Atan(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The arc tangent of the number

Source:
Returns:
Type
Expr

(inner) BitAnd(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to bitwise and together.

Source:
Returns:
Type
Expr

(inner) BitNot(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A numbers to provide the bitwise not.

Source:
Returns:
Type
Expr

(inner) BitOr(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to bitwise Or'd together.

Source:
Returns:
Type
Expr

(inner) BitXor(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to bitwise Xor'd together.

Source:
Returns:
Type
Expr

(inner) Bytes(bytes) → {Expr}

Parameters:
Name Type Description
bytes Uint8Array | ArrayBuffer | module:query~ExprArg

A base64 encoded string or a byte array

Source:
Returns:
Type
Expr

(inner) Call(ref, …args) → {Expr}

See the docs.

Invokes a given function passing in the provided arguments

Call(Ref("functions/a_function"), 1, 2)
Parameters:
Name Type Attributes Description
ref module:query~ExprArg

The ref of the UserDefinedFunction to call

args module:query~ExprArg <repeatable>

A series of values to pass as arguments to the UDF.

Source:
Returns:
Type
Expr

(inner) Casefold(string, normalizer) → {string}

See the docs.

Parameters:
Name Type Description
string string

The string to casefold.

normalizer string

The algorithm to use. One of: NFKCCaseFold, NFC, NFD, NFKC, NFKD.

Source:
Returns:

a normalized string

Type
string

(inner) Ceil(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The least integer that is greater than or equal to the number

Source:
Returns:
Type
Expr

(inner) Class(name, scopeopt) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
name module:query~ExprArg

The name of the class.

scope module:query~ExprArg <optional>

The Ref of the class's scope.

Deprecated:
  • Class is deprecated, use Collection instead
Source:
Returns:
Type
Expr

(inner) Classes(scopeopt) → {Expr}

See the docs.

Constructs a classes function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the class set's scope.

Source:
Returns:
Type
Expr

(inner) Collection(name, scopeopt) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
name module:query~ExprArg

The name of the collection.

scope module:query~ExprArg <optional>

The Ref of the collection's scope.

Source:
Returns:
Type
Expr

(inner) Collections(scopeopt) → {Expr}

See the docs.

Constructs a collections function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the collection set's scope.

Source:
Returns:
Type
Expr

(inner) Concat(strings, separator) → {string}

See the docs.

Parameters:
Name Type Description
strings string

A list of strings to concatenate.

separator string

The separator to use between each string.

Source:
Returns:

a single combined string

Type
string

(inner) Contains(path, in) → {Expr}

See the docs.

Parameters:
Name Type Description
path module:query~ExprArg

An array representing a path to check for the existence of.

in module:query~ExprArg

An object to search against.

Deprecated:
  • use ContainsPath instead
Source:
Returns:
Type
Expr

(inner) ContainsField(field, obj) → {Expr}

Parameters:
Name Type Description
field string

A field name we want to confirm exists.

obj module:query~ExprArg

An object to search against.

Source:
Returns:
Type
Expr

(inner) ContainsPath(path, in) → {Expr}

See the docs.

Parameters:
Name Type Description
path module:query~ExprArg

An array representing a path to check for the existence of.

in module:query~ExprArg

An object to search against.

Source:
Returns:
Type
Expr

(inner) ContainsStr(value, search) → {boolean}

Returns true if the string contains the given substring, or false if otherwise

Parameters:
Name Type Description
value string

the string to evaluate

search string

the substring to search for

Source:
See:
Returns:
  • was the search result found
Type
boolean

(inner) ContainsStrRegex(value, pattern) → {boolean}

Returns true if the string contains the given pattern, or false if otherwise

Parameters:
Name Type Description
value string

the string to evaluate

pattern string

the pattern to search for

Source:
See:
Returns:
  • was the regex search result found
Type
boolean

(inner) ContainsValue(value, in) → {Expr}

See the docs.

Parameters:
Name Type Description
value module:query~ExprArg

Represent the value we want to search for.

in module:query~ExprArg

An object we will search for the value passed in.

Source:
Returns:
Type
Expr

(inner) Cos(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The cosine of a number

Source:
Returns:
Type
Expr

(inner) Cosh(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The hyperbolic cosine of the number

Source:
Returns:
Type
Expr

(inner) Count(collection) → {integer}

Count the number of elements in the collection.

Parameters:
Name Type Description
collection array

array of items

Source:
See:
Returns:
  • number of items in the collection
Type
integer

(inner) Create(ref, paramsnullable) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
ref module:query~ExprArg

The Ref (usually a CollectionRef) to create.

params module:query~ExprArg <nullable>

An object representing the parameters of the document.

Source:
Returns:
Type
Expr

(inner) CreateAccessProvider(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a new access provider. - name: A valid schema name - issuer: A unique string - jwks_uri: A valid HTTPS URI - roles: An array of role/predicate pairs where the predicate returns a boolean. The array can also contain Role references.

Source:
Returns:
Type
Expr

(inner) CreateClass(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a class. - name (required): the name of the class to create

Deprecated:
  • use CreateCollection instead
Source:
Returns:
Type
Expr

(inner) CreateCollection(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a collection. - name (required): the name of the collection to create

Source:
Returns:
Type
Expr

(inner) CreateDatabase(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a database. - name (required): the name of the database to create

Source:
Returns:
Type
Expr

(inner) CreateFunction(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a new user defined function. - name: The name of the function - body: A lambda function (escaped with query).

Source:
Returns:
Type
Expr

(inner) CreateIndex(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create an index. - name (required): the name of the index to create - source: One or more source objects describing source collections and (optional) field bindings. - terms: An array of term objects describing the fields to be indexed. Optional - values: An array of value objects describing the fields to be covered. Optional - unique: If true, maintains a uniqueness constraint on combined terms and values. Optional - partitions: The number of sub-partitions within each term. Optional

Source:
Returns:
Type
Expr

(inner) CreateKey(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a new key - database: Ref of the database the key will be scoped to. Optional. - role: The role of the new key

Source:
Returns:
Type
Expr

(inner) CreateRole(params) → {Expr}

See the docs.

Parameters:
Name Type Description
params module:query~ExprArg

An object of parameters used to create a new role. - name: The name of the role - privileges: An array of privileges - membership: An array of membership bindings

Source:
Returns:
Type
Expr

(inner) Credentials(scopeopt) → {Expr}

See the docs.

Constructs a credentials functions that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the credential set's scope.

Source:
Returns:
Type
Expr

(inner) CurrentIdentity() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) CurrentToken() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) Database(name, scopeopt) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
name module:query~ExprArg

The name of the database.

scope module:query~ExprArg <optional>

The Ref of the database's scope.

Source:
Returns:
Type
Expr

(inner) Databases(scopeopt) → {Expr}

See the docs.

Constructs a databases functions that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the database set's scope.

Source:
Returns:
Type
Expr

(inner) Date(string) → {Expr}

See the docs.

Parameters:
Name Type Description
string module:query~ExprArg

A string to convert to a Date object

Source:
Returns:
Type
Expr

(inner) DayOfMonth(expression) → {Expr}

Returns a time expression's day of the month, from 1 to 31.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to day of month.

Source:
Returns:
Type
Expr

(inner) DayOfWeek(expression) → {Expr}

Returns a time expression's day of the week following ISO-8601 convention, from 1 (Monday) to 7 (Sunday).

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to day of week.

Source:
Returns:
Type
Expr

(inner) DayOfYear(expression) → {Expr}

Returns a time expression's day of the year, from 1 to 365, or 366 in a leap year.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to day of year.

Source:
Returns:
Type
Expr

(inner) Degrees(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

Take radians and convert it to degrees 360 degrees = 2 * pi radians

Source:
Returns:
Type
Expr

(inner) Delete(ref) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref to delete.

Source:
Returns:
Type
Expr

(inner) Difference(…sets) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
sets module:query~ExprArg <repeatable>

A list of SetRefs to diff.

Source:
Returns:
Type
Expr

(inner) Distinct(set) → {Expr}

See the docs.

Parameters:
Name Type Description
set module:query~ExprArg

A SetRef to remove duplicates from.

Source:
Returns:
Type
Expr

(inner) Divide(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to compute the quotient of.

Source:
Returns:
Type
Expr

(inner) Do(…args) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
args module:query~ExprArg <repeatable>

A series of expressions to run.

Source:
Returns:
Type
Expr

(inner) Documents(collection)

Returns a set of all documents in the given collection. A set must be paginated in order to retrieve its values.

Parameters:
Name Type Description
collection

a reference to the collection. Type: Ref

Source:
See:
Returns:

a new Expr instance

(inner) Drop(number, collection) → {Expr}

See the docs.

Parameters:
Name Type Description
number module:query~ExprArg

An expression resulting in the number of elements to drop from the collection.

collection module:query~ExprArg

An expression resulting in a collection.

Source:
Returns:
Type
Expr

(inner) EndsWith(value, search) → {boolean}

Returns true if the string ends with the given suffix value, or false if otherwise

Parameters:
Name Type Description
value string

the string to evaluate

search string

the suffix to search for

Source:
See:
Returns:
  • does value end with search
Type
boolean

(inner) Epoch(number, unit) → {Expr}

See the docs.

Parameters:
Name Type Description
number module:query~ExprArg

The number of units from Epoch

unit module:query~ExprArg

The unit of number. One of second, millisecond, microsecond, nanosecond.

Source:
Returns:
Type
Expr

(inner) Equals(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of expressions to check for equivalence.

Source:
Returns:
Type
Expr

(inner) Events(ref) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

A Ref or SetRef to retrieve an event set from.

Source:
Returns:
Type
Expr

(inner) Exists(ref, tsnullable) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
ref module:query~ExprArg

An expression resulting in a Ref.

ts module:query~ExprArg <nullable>

The snapshot time at which to check for the document's existence.

Source:
Returns:
Type
Expr

(inner) Exp(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The e raised to an exponent number

Source:
Returns:
Type
Expr

(inner) Filter(collection, lambda) → {Expr}

See the docs.

Parameters:
Name Type Description
collection module:query~ExprArg

An expression resulting in a collection to be filtered.

lambda module:query~ExprArg | function

A function that returns a boolean used to filter unwanted values.

Source:
Returns:
Type
Expr

(inner) FindStr(value, find, start) → {int}

See the docs.

Parameters:
Name Type Description
value string

A string to search.

find string

Find the first position of this string in the search string

start int

An optional start offset into the search string

Source:
Returns:

location of the found string or -1 if not found

Type
int

(inner) FindStrRegex(value, pattern, start, numResults) → {Array}

See the docs.

Parameters:
Name Type Description
value string

A string to search.

pattern string

Find the first position of this pattern in the search string using a java regular expression syntax

start int

An optional start offset into the search string

numResults int

An optional number of results to return, max 1024

Source:
Returns:

an array of object describing where the search pattern was located

Type
Array

(inner) Floor(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The greatest integer that is less than or equal to the number

Source:
Returns:
Type
Expr

(inner) Foreach(collection, lambda) → {Expr}

See the docs.

Parameters:
Name Type Description
collection module:query~ExprArg

An expression resulting in a collection to be iterated over.

lambda module:query~ExprArg | function

A function to be called for each element of the collection.

Source:
Returns:
Type
Expr

(inner) Format(string, values) → {string}

Format values into a string.

Parameters:
Name Type Description
string string

string with format specifiers

values array

list of values to format

Source:
Returns:

a string

Type
string

(inner) FunctionFn(name, scopeopt) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
name module:query~ExprArg

The name of the user defined function.

scope module:query~ExprArg <optional>

The Ref of the user defined function's scope.

Source:
Returns:
Type
Expr

(inner) Functions(scopeopt) → {Expr}

See the docs.

Constructs a functions function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the user defined function set's scope.

Source:
Returns:
Type
Expr

(inner) Get(ref, tsnullable) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
ref module:query~ExprArg

An expression resulting in either a Ref or SetRef.

ts module:query~ExprArg <nullable>

The snapshot time at which to get the document.

Source:
Returns:
Type
Expr

(inner) GT(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of terms to compare.

Source:
Returns:
Type
Expr

(inner) GTE(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of terms to compare.

Source:
Returns:
Type
Expr

(inner) HasCurrentIdentity() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) HasCurrentToken() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) HasIdentity() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) Hour(expression) → {Expr}

Returns a time expression's second of the minute, from 0 to 59.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a hour.

Source:
Returns:
Type
Expr

(inner) Hypot(…terms, …terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A side of the right triangle

terms module:query~ExprArg <repeatable>

The second side of a right triange, defaults to the first side

Source:
Returns:
Type
Expr

(inner) Identify(ref, password) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref to check the password against.

password module:query~ExprArg

The credentials password to check.

Source:
Returns:
Type
Expr

(inner) Identity() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) If(condition, then, else) → {Expr}

See the docs.

Parameters:
Name Type Description
condition module:query~ExprArg

An expression that returns a boolean.

then module:query~ExprArg

The expression to run if condition is true.

else module:query~ExprArg

The expression to run if the condition is false.

Source:
Returns:
Type
Expr

(inner) Index(name, scopeopt) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
name module:query~ExprArg

The name of the index.

scope module:query~ExprArg <optional>

The Ref of the index's scope.

Source:
Returns:
Type
Expr

(inner) Indexes(scopeopt) → {Expr}

See the docs.

Constructs an indexes function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the index set's scope.

Source:
Returns:
Type
Expr

(inner) Insert(ref, ts, action, params) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref to insert against

ts module:query~ExprArg

The valid time of the inserted event

action module:query~ExprArg

Whether the event should be a Create, Update, or Delete.

params module:query~ExprArg

If this is a Create or Update, the parameters of the document.

Source:
Returns:
Type
Expr

(inner) Intersection(…sets) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
sets module:query~ExprArg <repeatable>

A list of SetRefs to intersect.

Source:
Returns:
Type
Expr

(inner) IsArray(expr) → {Expr}

Check if the expression is an array.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsBoolean(expr) → {Expr}

Check if the expression is a boolean.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsBytes(expr) → {Expr}

Check if the expression is a byte array.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsCollection(expr) → {Expr}

Check if the expression is a collection.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsCredentials(expr) → {Expr}

Check if the expression is credentials.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsDatabase(expr) → {Expr}

Check if the expression is a database.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsDate(expr) → {Expr}

Check if the expression is a date.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsDoc(expr) → {Expr}

Check if the expression is a document (either a reference or an instance).

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsDouble(expr) → {Expr}

Check if the expression is a double.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsEmpty(collection) → {Expr}

See the docs.

Parameters:
Name Type Description
collection module:query~ExprArg

An expression resulting in a collection.

Source:
Returns:
Type
Expr

(inner) IsFunction(expr) → {Expr}

Check if the expression is a function.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsIndex(expr) → {Expr}

Check if the expression is an index.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsInteger(expr) → {Expr}

Check if the expression is an integer.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsKey(expr) → {Expr}

Check if the expression is a key.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsLambda(expr) → {Expr}

Check if the expression is a lambda.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsNonEmpty(collection) → {Expr}

See the docs.

Parameters:
Name Type Description
collection module:query~ExprArg

An expression resulting in a collection.

Source:
Returns:
Type
Expr

(inner) IsNull(expr) → {Expr}

Check if the expression is null.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsNumber(expr) → {Expr}

Check if the expression is a number.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsObject(expr) → {Expr}

Check if the expression is an object.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsRef(expr) → {Expr}

Check if the expression is a reference.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsRole(expr) → {Expr}

Check if the expression is a role.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsSet(expr) → {Expr}

Check if the expression is a set.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsString(expr) → {Expr}

Check if the expression is a string.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsTimestamp(expr) → {Expr}

Check if the expression is a timestamp.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) IsToken(expr) → {Expr}

Check if the expression is a token.

Parameters:
Name Type Description
expr module:query~ExprArg

The expression to check

Source:
See:
Returns:
Type
Expr

(inner) Join(source, target) → {Expr}

See the docs.

Parameters:
Name Type Description
source module:query~ExprArg

A SetRef of the source set

target module:query~ExprArg | function

A Lambda that will accept each element of the source Set and return a Set

Source:
Returns:
Type
Expr

(inner) KeyFromSecret(secret) → {Expr}

See the docs.

Parameters:
Name Type Description
secret module:query~ExprArg

The key or token secret to lookup.

Source:
Returns:
Type
Expr

(inner) Keys(scopeopt) → {Expr}

See the docs.

Constructs a keys function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the key set's scope.

Source:
Returns:
Type
Expr

(inner) Lambda(func) → {Expr}

See the docs.

Takes a Javascript function, and will transform it into the appropriate FaunaDB query. For example:

Lambda(function(a) { return Add(a, a); });
// Returns { lambda: 'a', expr: { add: [{ var: a }, { var: a }] } }

Note that the driver will handle wrapping all usages of the lambda's bound variables with the modules:query~Var function.

Parameters:
Name Type Description
func function

Takes the provided function and produces the appropriate FaunaDB query expression.

Source:
Returns:
Type
Expr

(inner) Length(value) → {int}

See the docs.

Parameters:
Name Type Description
value string

The string to calculate the length in codepoints.

Source:
Returns:

the length of the string in codepoints

Type
int

(inner) Let(bindings, in) → {Expr}

See the docs.

Parameters:
Name Type Description
bindings module:query~ExprArg

A set of bindings to use within the given expression.

in module:query~ExprArg

The expression to run with the given bindings.

Source:
Returns:
Type
Expr

(inner) Ln(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The natural log of the number

Source:
Returns:
Type
Expr

(inner) Log(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The log base 10 of a number

Source:
Returns:
Type
Expr

(inner) Login(ref, params) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

A Ref with credentials to authenticate against

params module:query~ExprArg

An object of parameters to pass to the login function - password: The password used to login

Source:
Returns:
Type
Expr

(inner) Logout(delete_tokens) → {Expr}

See the docs.

Parameters:
Name Type Description
delete_tokens module:query~ExprArg

If true, log out all tokens associated with the current session.

Source:
Returns:
Type
Expr

(inner) LowerCase(value) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to LowerCase.

Source:
Returns:

the string converted to lowercase

Type
string

(inner) LT(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of terms to compare.

Source:
Returns:
Type
Expr

(inner) LTE(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of terms to compare.

Source:
Returns:
Type
Expr

(inner) LTrim(value) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to trim leading white space.

Source:
Returns:

the string with leading white space removed

Type
string

(inner) Map(collection, lambda) → {Expr}

See the docs.

Parameters:
Name Type Description
collection module:query~ExprArg

An expression resulting in a collection to be mapped over.

lambda module:query~ExprArg | function

A function to be called for each element of the collection.

Source:
Returns:
Type
Expr

(inner) Match(index, …terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
index module:query~ExprArg

The Ref of the index to match against.

terms module:query~ExprArg <repeatable>

A list of terms used in the match.

Source:
Returns:
Type
Expr

(inner) Max(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to multiply together.

Source:
Returns:
Type
Expr

(inner) Mean(collection) → {float}

Returns the mean of all elements in the collection.

Parameters:
Name Type Description
collection array

collection the numbers

Source:
See:
Returns:
  • the mean of all numbers in the collection
Type
float

(inner) Merge(…merge, …_with, …lambda) → {Expr}

Merge two or more objects..

Parameters:
Name Type Attributes Description
merge module:query~ExprArg <repeatable>

merge the first object.

_with module:query~ExprArg <repeatable>

the second object or a list of objects

lambda module:query~ExprArg <repeatable>

a lambda to resolve possible conflicts

Source:
Returns:
Type
Expr

(inner) Min(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to multiply together.

Source:
Returns:
Type
Expr

(inner) Minute(expression) → {Expr}

Returns a time expression's second of the minute, from 0 to 59.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a month.

Source:
Returns:
Type
Expr

(inner) Modulo(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to compute the quotient of. The remainder will be returned.

Source:
Returns:
Type
Expr

(inner) Month(expression) → {Expr}

Returns a time expression's month of the year, from 1 to 12.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a month.

Source:
Returns:
Type
Expr

(inner) MoveDatabase(from, to) → {Expr}

Move database to a new hierarchy.

Parameters:
Name Type Description
from string

database reference to be moved.

to string

new parent database reference.

Source:
See:
Returns:

The expression wrapping the provided object.

Type
Expr

(inner) Multiply(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to multiply together.

Source:
Returns:
Type
Expr

(inner) NewId() → {Expr}

See the docs.

Source:
Returns:
Type
Expr

(inner) NextId() → {Expr}

See the docs.

Deprecated:
  • use NewId instead
Source:
Returns:
Type
Expr

(inner) NGram(terms, optsnullable) → {Array|Value}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg

A document from which to produce ngrams.

opts Object <nullable>

An object of options - min: The minimum ngram size. - max: The maximum ngram size.

Source:
Returns:
Type
Array | Value

(inner) Not(boolean) → {Expr}

See the docs.

Parameters:
Name Type Description
boolean module:query~ExprArg

A boolean to produce the negation of.

Source:
Returns:
Type
Expr

(inner) Now() → {Expr}

Returns the current snapshot time.

Source:
See:
Returns:
Type
Expr

(inner) objectFunction(…fields) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
fields module:query~ExprArg <repeatable>

The object to be escaped.

Source:
Returns:
Type
Expr

(inner) Or(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection to compute the disjunction of.

Source:
Returns:
Type
Expr

(inner) Paginate(set, optsnullable) → {Expr}

See the docs. You may want to utilize Client#paginate to obtain a PageHelper, rather than using this query function directly.

Parameters:
Name Type Attributes Description
set module:query~ExprArg

An expression resulting in a SetRef to page over.

opts Object <nullable>

An object representing options for pagination.

  • size: Maximum number of results to return.
  • after: Return the next page of results after this cursor (inclusive).
  • before: Return the previous page of results before this cursor (exclusive).
  • sources: If true, include the source sets along with each element.
Source:
Returns:
Type
Expr

(inner) Pow(…terms, …terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A numbers to raise to the power.

terms module:query~ExprArg <repeatable>

An optional exponent

Source:
Returns:
Type
Expr

(inner) Prepend(elements, collection) → {Expr}

See the docs.

Parameters:
Name Type Description
elements module:query~ExprArg

An expression resulting in a collection of elements to prepend to the given collection.

collection module:query~ExprArg

An expression resulting in a collection.

Source:
Returns:
Type
Expr

(inner) Query(lambda) → {Expr}

See the docs.

Constructs a @query type using the Lambda() or a function.

Query(Lambda(['a', 'b'], Add(Var('a'), Var('b'))))
Query(function (a, b) { return Add(a, b) })
Parameters:
Name Type Description
lambda module:query~ExprArg | function

A function to escape as a query.

Source:
Returns:
Type
Expr

(inner) Radians(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

Take degrees and convert the number to radians 2 * pi = 360 degrees

Source:
Returns:
Type
Expr

(inner) Range(set, from, to) → {Expr}

See the docs.

Parameters:
Name Type Description
set module:query~ExprArg

A SetRef of the source set

from module:query~ExprArg

The lower bound

to module:query~ExprArg

The upper bound

Source:
Returns:
Type
Expr

(inner) Reduce(lambda, initial, collection) → {Expr}

See the docs.

Parameters:
Name Type Description
lambda module:query~ExprArg

The accumulator function

initial module:query~ExprArg

The initial value

collection module:query~ExprArg

The colleciton to be reduced

Source:
Returns:
Type
Expr

(inner) Ref(ref|cls, idopt) → {Expr}

If one parameter is provided, constructs a literal Ref value. The string collections/widget/123 will be equivalent to new values.Ref('123', new values.Ref('widget', values.Native.COLLECTIONS))

If two are provided, constructs a Ref() function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
ref|cls string | module:query~ExprArg

Alone, the ref in path form. Combined with id, must be a collection ref.

id module:query~ExprArg <optional>

A numeric id of the given collection.

Source:
Returns:
Type
Expr

(inner) RegexEscape(value) → {string}

It takes a string and returns a regex which matches the input string verbatim.

Parameters:
Name Type Description
value

the string to analyze

Source:
See:
Returns:
  • a regex which matches the input string verbatim
Type
string

(inner) Remove(ref, ts, action) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref of the document whose event should be removed.

ts module:query~ExprArg

The valid time of the event.

action module:query~ExprArg

The event action (Create, Update, or Delete) that should be removed.

Source:
Returns:
Type
Expr

(inner) Repeat(value, number) → {string}

See the docs.

Parameters:
Name Type Description
value string

A string to repeat.

number int

The number of times to repeat the string

Source:
Returns:

a string which was repeated

Type
string

(inner) Replace(ref, params) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref to replace.

params module:query~ExprArg

An object representing the parameters of the document.

Source:
Returns:
Type
Expr

(inner) ReplaceStr(value, find, replace) → {String}

See the docs.

Parameters:
Name Type Description
value string

A string to search.

find string

The string to find in the search string

replace string

The string to replace in the search string

Source:
Returns:

all the occurrences of find substituted with replace string

Type
String

(inner) ReplaceStrRegex(value, pattern, replace, first) → {string}

See the docs.

Parameters:
Name Type Description
value string

A string to search.

pattern string

The pattern to find in the search string using a java regular expression syntax

replace string

The string to replace in the search string

first boolean

Replace all or just the first

Source:
Returns:

all the occurrences of find pattern substituted with replace string

Type
string

(inner) Reverse(expr) → {Expr}

Parameters:
Name Type Description
expr module:query~ExprArg

An expression (i.e. Set, Page, or Array) to reverse

Source:
Returns:
Type
Expr

(inner) Role(name, scopeopt) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
name module:query~ExprArg

The name of the role.

scope module:query~ExprArg <optional>

The Ref of the role's scope.

Source:
Returns:
Type
Expr

(inner) Roles(scopeopt) → {Expr}

See the docs.

Constructs a roles function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the role set's scope.

Source:
Returns:
Type
Expr

(inner) Round(…terms, …terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A numbers to round.

terms module:query~ExprArg <repeatable>

An optional precision

Source:
Returns:
Type
Expr

(inner) RTrim(value) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to remove white space from the end.

Source:
Returns:

the string with trailing whitespaces removed

Type
string

(inner) Second(expression) → {Expr}

Returns a time expression's second of the minute, from 0 to 59.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a month.

Source:
Returns:
Type
Expr

(inner) Select(path, from, defaultnullable) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
path module:query~ExprArg

An array representing a path to pull from an object.

from module:query~ExprArg

The object to select from

default module:query~ExprArg <nullable>

A default value if the path does not exist.

Source:
Returns:
Type
Expr

(inner) SelectAll(path, from) → {Expr}

See the docs.

Parameters:
Name Type Description
path module:query~ExprArg

An array representing a path to pull from an object.

from module:query~ExprArg

The object to select from

Deprecated:
  • avoid using
Source:
Returns:
Type
Expr

(inner) Sign(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The sign of the number is returned as positive 1, zero 0 , negative -1

Source:
Returns:
Type
Expr

(inner) Sin(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The sine of a number

Source:
Returns:
Type
Expr

(inner) Singleton(ref) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref of the document for which to retrieve the singleton set.

Source:
Returns:
Type
Expr

(inner) Sinh(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The hyperbolic sine of a number

Source:
Returns:
Type
Expr

(inner) Space(num) → {string}

See the docs.

Parameters:
Name Type Description
num int

The string of N Space(s).

Source:
Returns:

a string with spaces

Type
string

(inner) Sqrt(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The square root of the number

Source:
Returns:
Type
Expr

(inner) StartsWith(value, search) → {boolean}

Returns true if the string starts with the given prefix value, or false if otherwise

Parameters:
Name Type Description
value string

the string to evaluate

search string

the prefix to search for

Source:
See:
Returns:
  • does value start with search
Type
boolean

(inner) SubString(value, start, length) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to SubString.

start int

The position the first character of the return string begins at

length int

An optional length, if omitted then returns to the end of string

Source:
Returns:
Type
string

(inner) Subtract(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A collection of numbers to compute the difference of.

Source:
Returns:
Type
Expr

(inner) Sum(collection) → {integer}

Sum the elements in the collection.

Parameters:
Name Type Description
collection array

collection of numbers

Source:
See:
Returns:
  • total of all numbers in collection
Type
integer

(inner) Take(number, collection) → {Expr}

See the docs.

Parameters:
Name Type Description
number module:query~ExprArg

An expression resulting in the number of elements to take from the collection.

collection module:query~ExprArg

An expression resulting in a collection.

Source:
Returns:
Type
Expr

(inner) Tan(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The Tangent of a number

Source:
Returns:
Type
Expr

(inner) Tanh(…terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

The hyberbolic tangent of a number

Source:
Returns:
Type
Expr

(inner) Time(string) → {Expr}

See the docs.

Parameters:
Name Type Description
string module:query~ExprArg

A string to converted to a time object.

Source:
Returns:
Type
Expr

(inner) TimeAdd(base, offset, unit) → {Expr}

See the docs.

Returns a new time or date with the offset in terms of the unit added.

Parameters:
Name Type Description
base

the base time or data

offset

the number of units

unit

the unit type

Source:
Returns:
Type
Expr

(inner) TimeDiff(start, finish, unit) → {Expr}

See the docs.

Returns the number of intervals in terms of the unit between two times or dates. Both start and finish must be of the same type.

Parameters:
Name Type Description
start

the starting time or date, inclusive

finish

the ending time or date, exclusive

unit

the unit type

Source:
Returns:
Type
Expr

(inner) TimeSubtract(base, offset, unit) → {Expr}

See the docs.

Returns a new time or date with the offset in terms of the unit subtracted.

Parameters:
Name Type Description
base

the base time or data

offset

the number of units

unit

the unit type

Source:
Returns:
Type
Expr

(inner) TitleCase(value) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to TitleCase.

Source:
Returns:

A string converted to titlecase

Type
string

(inner) ToArray(expression) → {Expr}

Converts an expression to an Array.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to an Array.

Source:
Returns:
Type
Expr

(inner) ToDate(expression) → {Expr}

Converts an expression to a date literal.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a date.

Source:
Returns:
Type
Expr

(inner) ToDouble(expression) → {Expr}

Converts an expression to a double value, if possible.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a double.

Source:
Returns:
Type
Expr

(inner) ToInteger(expression) → {Expr}

Converts an expression to an integer value, if possible.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to an integer.

Source:
Returns:
Type
Expr

(inner) Tokens(scopeopt) → {Expr}

See the docs.

Constructs a tokens function that, when evaluated, returns a Ref value.

Parameters:
Name Type Attributes Description
scope module:query~ExprArg <optional>

The Ref of the token set's scope.

Source:
Returns:
Type
Expr

(inner) ToMicros(expression) → {Expr}

Converts a time expression to microseconds since the UNIX epoch.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to microsecond numeric value.

Source:
Returns:
Type
Expr

(inner) ToMillis(expression) → {Expr}

Converts a time expression to milliseconds since the UNIX epoch.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to millisecond numeric value.

Source:
Returns:
Type
Expr

(inner) ToNumber(expression) → {Expr}

Converts an expression to a number literal.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a number.

Source:
Returns:
Type
Expr

(inner) ToObject(expression) → {Expr}

Converts an expression to an Object.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to an Object.

Source:
Returns:
Type
Expr

(inner) ToSeconds(expression) → {Expr}

Converts an expression evaluating to a time to seconds since epoch.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to seconds numeric value.

Source:
Returns:
Type
Expr

(inner) ToString(expression) → {Expr}

Converts an expression to a string literal.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a string.

Source:
Returns:
Type
Expr

(inner) ToTime(expression) → {Expr}

Converts an expression to a time literal.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a time.

Source:
Returns:
Type
Expr

(inner) Trim(value) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to Trim.

Source:
Returns:

a string with leading and trailing whitespace removed

Type
string

(inner) Trunc(…terms, …terms) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
terms module:query~ExprArg <repeatable>

A numbers to truncate.

terms module:query~ExprArg <repeatable>

An optional precision

Source:
Returns:
Type
Expr

(inner) Union(…sets) → {Expr}

See the docs.

Parameters:
Name Type Attributes Description
sets module:query~ExprArg <repeatable>

A list of SetRefs to union together.

Source:
Returns:
Type
Expr

(inner) Update(ref, params) → {Expr}

See the docs.

Parameters:
Name Type Description
ref module:query~ExprArg

The Ref to update.

params module:query~ExprArg

An object representing the parameters of the document.

Source:
Returns:
Type
Expr

(inner) UpperCase(value) → {string}

See the docs.

Parameters:
Name Type Description
value string

The string to Uppercase.

Source:
Returns:

An uppercase string

Type
string

(inner) Var(varName) → {Expr}

See the docs.

Parameters:
Name Type Description
varName module:query~ExprArg

The name of the bound var.

Source:
Returns:
Type
Expr

(inner) Year(expression) → {Expr}

Returns the time expression's year, following the ISO-8601 standard.

Parameters:
Name Type Description
expression module:query~ExprArg

An expression to convert to a year.

Source:
Returns:
Type
Expr

Type Definitions

ExprArg

Type:
Source:

ExprTerm

Type:
  • Expr | string | number | boolean | Object
Source: