# Fauna tour Fauna is a truly serverless database that combines document flexibility with native relational capabilities, offering auto-scaling, multi-active replication, and HTTPS connectivity. This tour guides you through the process of building a basic JavaScript app with Fauna, highlighting Fauna’s unique features and developer experience. ## [](#distributed-serverless-architecture)Distributed, serverless architecture Fauna databases are easy to set up and fully managed — no provisioning, capacity planning, or operational overhead required. Create a database To kick things off, create a database for your app: 1. Log in to the [Fauna Dashboard](https://dashboard.fauna.com/). You can sign up for a free account at [https://dashboard.fauna.com/register](https://dashboard.fauna.com/register). 2. Create a database with the following configuration: * **Region group**: Choose your preferred [region group](../../manage/region-groups/). The region group determines the geographic regions in which your data resides. * **Use demo data**: Enabled. This option populates the database with sample e-commerce data and schema we’ll use later in the tour. * **Enable backups**: Disabled. For a production database, use this feature to automatically [create daily backups](../../manage/backups/) that you can restore in case of operator errors, such as accidental deletion. Leave the other options as is. That’s it! Your database is instantly allocated and ready for queries. Your database’s data is automatically replicated across regions in its region group, ensuring high availability and resilience to outages. ### [](#virtual-private-fauna-vpf)Virtual Private Fauna (VPF) For enhanced security and customization, Fauna offers [Virtual Private Fauna (VPF)](https://fauna.com/virtual-private-fauna). This option provides single-tenant deployments on dedicated infrastructure with a customizable regional footprint across multiple cloud providers. VPF is designed to meet specific security and compliance requirements for organizations with more stringent needs. ## [](#api-delivery-model)API delivery model In Fauna, every query is a transaction, ensuring ACID compliance across all operations, even in globally distributed region groups. Fauna uses stateless, token-based authentication. Each query is an independently authenticated request to the global [Query HTTP API endpoint](../../reference/http/reference/core-api/#operation/query). Fauna routes and authorizes queries using an [authentication secret](../../learn/security/authentication/), which is scoped to a specific database. Fauna uses replicas and intelligent routing to ensure queries have low latency. Create an authentication secret Fauna supports several types of authentication secrets. For this tour, create a [key](../../learn/security/keys/), which is one type of secret: 1. In the Dashboard’s **Explorer** page, select your demo database. 2. In the database’s **Keys** tab, click **Create Key**. 3. Choose a **Role** of **admin**. 4. Click **Save**. ![Create a key](../_images/create-key.gif) 5. Copy the **Key Secret**. You’ll use the secret later in the tour. ### [](#client-drivers)Client drivers To run queries, your app can work directly with the [Fauna Core HTTP API](../../reference/http/reference/core-api/) or use a Fauna [client driver](../../build/drivers/) for your preferred programming language: ![JavaScript](../../build/_images/drivers/logos/javascript.svg) [JavaScript](../../build/drivers/js-client/) ![Python](../../build/_images/drivers/logos/python.svg) [Python](../../build/drivers/py-client/) ![Go](../../build/_images/drivers/logos/golang.svg) [Go](../../build/drivers/go-client/) ![C#](../../build/_images/drivers/logos/csharp.svg) [.NET/C#](../../build/drivers/dotnet-client/) ![Java](../../build/_images/drivers/logos/java.svg) [Java](../../build/drivers/jvm-client/) Each driver is an open-source wrapper for the HTTP API. They’re maintained by Fauna and lightweight enough for use in serverless functions, edge networks, or other resource-constrained environments. ![The Fauna client driver model](../_images/client-model.svg) Add Fauna to a Node.js app Next, create a basic Node.js app using the [Fauna JavaScript driver](../../build/drivers/js-client/): 1. Create a directory for the app and install the driver: ```bash mkdir app cd app npm install fauna ``` 2. Set the `FAUNA_SECRET` environment variable to your key’s secret. Fauna’s client drivers can access the secret from this variable: ```bash export FAUNA_SECRET= ``` 3. Create an `app.mjs` file and add the following code: ```javascript import { Client, fql } from "fauna"; // Initialize the Fauna client. const client = new Client(); // Compose a query using an FQL template string. const query = fql`Product.all() { name, description, price }`; // Run the query. const pages = client.paginate(query); // Iterate through the results const products = []; for await (const product of pages.flatten()) { products.push(product) } console.log(products) // Close the client. client.close(); ``` 4. Run the app: ```bash node app.mjs ``` The app prints the following data from your demo database: ```javascript [ { name: 'cups', description: 'Translucent 9 Oz, 100 ct', price: 698 }, { name: 'donkey pinata', description: 'Original Classic Donkey Pinata', price: 2499 }, ... ] ``` ## [](#fauna-query-language)Fauna Query Language You use the [Fauna Query Language (FQL)](../../learn/query/) to read and write data in a Fauna database. Fauna stores data as JSON-like [documents](../../learn/data-model/documents/), organized into [collections](../../learn/data-model/collections/). Queries can filter and fetch documents from a collection as a [Set](../../learn/data-model/sets/), and iterate through each document. Run a query in the Dashboard Shell In addition to your sample app, you can use the Dashboard Shell to run FQL queries for testing or one-off queries. To test it out, re-run the query from your sample app: ```fql Product.all() { name, description, price } ``` The query fetches all documents from the `Product` collection as a Set. ![Run an FQL query in the Dashboard Shell](../_images/dashboard-shell-query.gif) ### [](#static-typing)Static typing FQL is a TypeScript-inspired language and includes optional [static typing](../../learn/query/#static-typing). You can use typing to catch errors early in development, improving code quality and reducing runtime issues. ### [](#relational-queries)Relational queries FQL also offers a concise, expressive syntax for [relational queries](../../learn/data-model/relationships/), supporting complex joins and data transformations: ```fql // Gets the first customer with an email of // "alice.appleseed@example.com". Use an index with // terms, such as `byEmail()`, for better performance. let customer = Customer.where(.email == "alice.appleseed@example.com") .first() // Gets the first order for the customer, // sorted by descending creation time. // Use an index for better performance. Order.where(.customer == customer) .order(desc(.createdAt)). first() { // Project fields from the order. // The order contains fields with document references. // Projecting the fields resolves references, // similar to a SQL join. // `Customer` document reference: customer { name, email }, status, createdAt, items { // Nested `Product` document reference: product { name, price, stock, // `Category` document reference: category { name } }, quantity }, total } ``` ### [](#user-defined-functions-udfs)User-defined functions (UDFs) You can save and reuse FQL statements as [user-defined functions (UDFs)](../../learn/schema/user-defined-functions/), which work similarly to stored procedures in SQL. UDFs let you encapsulate and store business logic in your database, promoting code reuse and maintaining a clear separation of concerns. ## [](#schema-as-code)Schema as code [Fauna Schema Language (FSL)](../../learn/schema/) lets you define and manage database schema as code. You can manage your database’s FSL schema using the Dashboard or as `.fsl` files using the [Fauna CLI](../../build/cli/v4/). Using the CLI lets you: * Store `.fsl` schema files alongside your application code * Pull and push schema to your Fauna database from a local directory * Place database schema under version control * Deploy schema with [CI/CD pipelines](../../learn/schema/manage-schema/#cicd) * Change your production schema as your app evolves using [progressive schema enforcement](../../learn/schema/#type-enforcement) and [zero-downtime migrations](../../learn/schema/#schema-migrations) Manage schema using the Fauna CLI Fauna’s demo dataset includes FSL schema for several resources. Install the Fauna CLI and pull your demo databases’s schema into your app’s project directory. 1. Install the Fauna CLI: ```bash npm install -g fauna-shell ``` 2. If you haven’t already, log in to Fauna using the CLI: ```cli fauna login ``` 3. Create and navigate to a schema directory. The directory can have any name. ```bash mkdir schema cd schema ``` 4. Pull your database’s schema into the project directory: ```cli # Authenticated using the 'FAUNA_SECRET' env var. fauna schema pull ``` When prompted, accept and pull the changes. The command saves the schema as `.fsl` files in the `schema` directory. For example, `collections.fsl` contains [collection schema](../../learn/schema/#collection-schema) for the database: ```fsl collection Customer { name: String email: String address: { street: String, city: String, state: String, postalCode: String, country: String } compute cart: Order? = (customer => Order.byCustomerAndStatus(customer, 'cart').first()) // Use a computed field to get the Set of Orders for a customer. compute orders: Set = ( customer => Order.byCustomer(customer)) // Use a unique constraint to ensure no two customers have the same email. unique [.email] index byEmail { terms [.email] } } ... ``` ## [](#change-data-capture-cdc-and-real-time-events)Change data capture (CDC) and real-time events Fauna [event sources](../../learn/cdc/) let you build change data capture (CDC) and real-time features for your app. An event source tracks changes to a specific Set of documents or document fields, defined by an FQL query. The event source emits an event whenever a tracked change occurs. An app can consume an event source in two ways: **Event feeds** : Asynchronous requests that poll the event source for paginated events. **Event streams**: Real-time subscriptions that push events from the event source to your application using an open connection to Fauna. Subscribe to an event stream Update your app to subscribe to a real-time event stream. As a test, track changes to the demo database’s `Customer` collection. 1. Open your app’s `app.mjs` file and replace the app’s code with the following: ```javascript import { Client, fql } from "fauna"; const client = new Client(); // Create an event source by appending `eventSource()` // to a query that returns a supported Set of documents. const query = fql`Customer.all().eventSource() { name, email }`; // Start an event stream using the query. const stream = client.stream(query); // Print each event from the stream. for await (const event of stream) { console.log("Stream event:", event); } client.close(); ``` 2. Run the app: ```bash node app.mjs ``` Event streams require an open connection so leave the app running. 3. In the Dashboard Shell, run the following FQL query to update a tracked `Customer` collection document: ```fql // Creates a `Customer` collection document. Customer.create({ name: "John Doe", email: "john.doe@example.com", address: { street: "87856 Mendota Court", city: "Washington", state: "District of Columbia", postalCode: "20220", country: "US" } }) ``` When you run the query, the app data from the related event: ```javascript Stream event: { type: 'add', data: { name: 'John Doe', email: 'john.doe@example.com' }, txn_ts: 1727127627405000, cursor: 'gsGCGmbx4EsaGCPPQAA=', stats: { read_ops: 1, storage_bytes_read: 207, compute_ops: 1, processing_time_ms: 8, rate_limits_hit: [] } } ``` 4. Press Ctrl+C to stop the app. ## [](#security-and-access-control)Security and access control Fauna supports both [role-based access control (RBAC)](../../learn/security/roles/) for coarse-grained permissions and [attribute-based access control (ABAC)](../../learn/security/abac/) for fine-grained, dynamic access rules. ### [](#built-in-user-authentication)Built-in user authentication Fauna includes a built-in end-user authentication system called [tokens](../../learn/security/tokens/). Each token is associated with an [identity document](../../learn/security/tokens/#identity-document) representing an end user, system, or other identity. A [credential](../../learn/security/tokens/#credentials) associates an end user’s password with the identity document. With ABAC, you can use [FQL predicates](../../reference/fql/functions/#predicates) to dynamically grant roles and privileges based on the attributes of identity documents, the query, and other context. Create an end-user authentication token with ABAC Next, you’ll extend the demo dataset with a role for customer end users. Use the existing `Customer` collection to store these end user’s identity documents. Then create a token for a customer and use it to authenticate a query. 1. In your project’s `schema` directory, create a `roles.fsl` file and add the following FSL role schema to it: ```fsl // Defines the customer role. role customer { // Assign the customer role to tokens with // an identity document in the Customer collection. membership Customer // Grant read access to the Product collection. privileges Product { read } // Grant read access to the Category collection. privileges Category { read } // If the predicate is true, // grant `read` access to the Customer collection. privileges Customer { read { // The customer can only access their own // Customer identity document. // Check that the Customer document // is the token's identity document. predicate (doc => doc == Query.identity()) } } } ``` 2. Save `roles.fsl`. Then push the schema to Fauna: ```cli # Authenticated using the 'FAUNA_SECRET' env var. fauna schema push ``` When prompted, accept and stage the schema. 3. Check the status of the staged schema: ```cli fauna schema status ``` 4. When the status is `ready`, commit the staged schema to the database: ```cli fauna schema commit ``` The commit applies the staged schema to the database. This creates the role. 5. In the Dashboard Shell, run the following FQL query to: * Create a `Customer` collection that serves as an identity document. * Create a credential that associates the identity document with a password. * Create a token using the credential. ```fql let customer = Customer.create({ name: "Jane Doe", email: "jane.doe@example.com", address: { street: "87856 Mendota Court", city: "Washington", state: "District of Columbia", postalCode: "20220", country: "US" } }) let credentials = Credential.create({ document: customer, password: "SAMPLE_PASSWORD" }) credentials.login("SAMPLE_PASSWORD") ``` The query returns a token document with a `secret`. You can use the authentication `secret` to authenticate requests on behalf of the user. ``` { id: "409855969129922637", // Auto-generated ID for the token document. coll: Token, ts: Time("2099-09-23T21:46:01.200Z"), document: Customer("409855969112096845"), // Reference for the token's identity document. secret: "fn..." } ``` 6. To test out the secret and role, paste it into the Dashboard Shell’s authentication drop-down, selecting **Secret**. ![Create a key](../_images/auth-dropdown.gif) 7. Then use the secret to run an FQL query that accesses a collection with limited privileges, such as the `Customer` collection: ```fql Customer.all() { name, email } ``` Based on its role and privileges, the secret can only access the token’s `Customer` identity document. Other `Customer` documents are omitted from the results: ``` { data: [ { name: "Jane Doe", email: "jane.doe@example.com" } ] } ``` ### [](#third-party-authentication)Third-party authentication Fauna also supports integrations with third-party identity providers. ![Auth0](../../build/_images/integration/logos/auth0.png) [Auth0](../../build/integration/auth0/) ![Clerk](../../build/_images/integration/logos/clerk.svg) [Clerk](../../build/integration/clerk/) ![Amazon Cognito](../../build/_images/integration/logos/cognito.png) [Amazon Cognito](../../build/integration/cognito/) ![Microsoft Entra](../../build/_images/integration/logos/entra.svg) [Microsoft Entra](../../build/integration/entra/) ## [](#database-model-and-multi-tenancy)Database model and multi-tenancy Fauna’s [database model](../../learn/data-model/databases/) makes it easy to create databases for isolated environments, such as staging and production, and multi-tenant applications: * Each Fauna database can have many child databases. You can use child databases as tenants for your application. * All databases, including [child databases](../../learn/data-model/databases/), are instantly allocated without provisioning or warmup. * Each database is logically isolated from its peers with separate access controls. * All Fauna resources, excluding top-level keys, exist as documents within a specific database. This includes collections, user-defined functions, and child databases. * Queries run in the context of a single database and can’t access data outside the database. Databases aren’t aware of their parents or peers. Create a child database You can use FQL queries to programmatically create [child databases](../../learn/data-model/databases/). Child databases are represented as `Database` collection documents in the parent database. To create a child database, run the following query as an **Admin** in the Dashboard Shell: ```fql // Create a child database named `child_db` Database.create({ name: "child_db", typechecked: true, priority: 10 }) ``` You can populate and access the database’s data using a [secret](../../learn/security/authentication/) that’s scoped to the database. You can use a [scoped key](../../learn/security/keys/#scoped-keys) to manage a child database’s data from its parent database. ## [](#next-steps)Next steps Congratulations — You’ve completed the tour! 🏆 This introduction is just the tip of the iceberg. There’s much more of Fauna to explore. To help you on your journey, we’ve curated a selection of resources below. [Cheat sheet](../../reference/fql-api/cheat-sheet/) A quick reference for FQL methods, grouped by functionality. [Sample apps](../../build/sample-apps/) Learn how to use Fauna through a sample application. [Workshops](../../build/workshops/) Build solutions with Fauna following best practices. [Set up a project](../../build/tutorials/project/) Create a project for an app using the Fauna CLI and FSL. [Security](../../learn/security/) Set up access control in Fauna using RBAC and ABAC. [Query patterns](../../learn/query/patterns/) Learn about common FQL query patterns, including basic CRUD operations. # CRUD and basic operations This page contains examples of CRUD queries and other common database operations in Fauna Query Language (FQL) and Fauna Schema Language (FSL). ## [](#collections)Collections ### [](#create-a-collection)Create a collection To create a collection, add an FSL [collection schema](../../../../reference/fsl/collection/) to Fauna using a [staged schema change](../../../schema/manage-schema/#staged). ```fsl // Defines the `Customer` collection. collection Customer { // Field definitions. // Define the structure of the collection's documents. name: String email: String address: { street: String city: String state: String postalCode: String country: String } // Wildcard constraint. // Allows arbitrary ad hoc fields of any type. *: Any // If a collection schema has no field definitions // and no wildcard constraint, it has an implicit // wildcard constraint of `*: Any`. } ``` | See Schema | | --- | --- | --- | ### [](#edit-a-collection)Edit a collection Update a collection’s document type using a [zero-downtime schema migration](../../../schema/#schema-migrations): ```fsl collection Customer { name: String email: String address: { street: String city: String state: String postalCode: String country: String } // Adds the `points` field. Accepts `int` or `null` values. // Accepting `null` means the field is not required. points: Int? // Adds the `typeConflicts` field as a catch-all field for // existing `points` values that aren't `Int` or `null`. typeConflicts: { *: Any }? *: Any migrations { // Adds the `typeConflicts` field. add .typeConflicts // Adds the `points` field. add .points // Nests non-conforming `points` and `typeConflicts` // field values in the `typeConflicts` catch-all field. move_conflicts .typeConflicts } } ``` | See Schema migrations | | --- | --- | --- | ### [](#view-collections)View collections ```fql Collection.all() ``` | Reference: Collection.all() | | --- | --- | --- | ### [](#delete-a-collection)Delete a collection To delete a collection, delete its schema using any of the following: * The [Fauna CLI](../../../schema/manage-schema/#staged) * The [Fauna Dashboard](https://dashboard.fauna.com/) * The Fauna Core HTTP API’s [Schema endpoints](../../../../reference/http/reference/core-api/#tag/Schema) * The FQL [`collectionDef.delete()`](../../../../reference/fql-api/collection/delete/) method. Deleting a collection deletes its documents and indexes. ## [](#documents)Documents ### [](#create-a-document)Create a document ```fql // Creates a `Customer` collection document. Customer.create({ name: "John Doe", email: "john.doe@example.com", address: { street: "123 Main St", city: "San Francisco", state: "CA", postalCode: "12345", country: "United States" } }) ``` | Reference: collection.create() | | --- | --- | --- | ### [](#get-a-single-document)Get a single document ```fql // Gets a `Customer` collection document. // Replace `111` with a document `id`. Customer.byId("111") ``` | Reference: collection.byId() | | --- | --- | --- | ### [](#update-a-document)Update a document ```fql // Updates a `Customer` collection document. Customer.byId("111")?.update({ // Updates the existing `name` field value. name: "Jonathan Doe", // Adds new `points` field. points: 42 }) ``` | Reference: document.update() | | --- | --- | --- | ### [](#upsert-a-document)Upsert a document ```fql // Try to find an existing customer. // If the customer doesn't exist, returns `null`. let customer = Customer.byId("111") // Customer data to upsert let data = { name: "Alice Appleseed", email: "alice.appleseed@example.com", address: { street: "87856 Mendota Court", city: "Washington", state: "DC", postalCode: "20220", country: "US" } } // Create or update the customer // based on existence. if (customer == null) { Customer.create(data) } else { customer!.update(data) } ``` ### [](#remove-a-document-field)Remove a document field ```fql // Updates a `Customer` collection document. Customer.byId("111")?.update({ // Removes the `points` field. points: null }) ``` | Reference: document.update() | | --- | --- | --- | ### [](#replace-a-document)Replace a document ```fql // Replaces a `Customer` collection document. Customer.byId("111")?.replace({ name: "Jane Doe", email: "jane.doe@example.com", address: { street: "87856 Mendota Court", city: "Washington", state: "DC", postalCode: "20220", country: "US" } }) ``` | Reference: document.replace() | | --- | --- | --- | ### [](#delete-a-document)Delete a document ```fql // Deletes a `Customer` collection document. Customer.byId("111")?.delete() ``` | Reference: document.delete() | | --- | --- | --- | ### [](#bulk-writes)Bulk writes Use [`set.forEach()`](../../../../reference/fql-api/set/foreach/) to iteratively update each document in a Set: ```fql // Get a Set of `Customer` collection documents with an // `address` in the `state` of `DC`. let customers = Customer.where(.address?.state == "DC") // Use `forEach()` to update each document in the previous Set. customers.forEach(doc => doc.update({ address: { street: doc?.address?.street, city: doc?.address?.city, state: "District of Columbia", postalCode: doc?.address?.postalCode, country: doc?.address?.country, } })) // `forEach()` returns `null`. ``` For more examples, see [Bulk writes](../bulk-writes/). | Reference: set.forEach() | | --- | --- | --- | ## [](#indexes-and-reads)Indexes and reads ### [](#create-an-index)Create an index You define indexes in FSL as part of a [collection schema](../../../../reference/fsl/collection/): ```fsl collection Customer { ... index byEmail { // `terms` are document fields for exact match searches. // In this example, you get `Customer` collection documents // by their `email` field value. terms [.email] // `values` are document fields for sorting and range searches. // In this example, you sort or filter index results by their // descending `name` and `email` field values. values [.name, .email] } } ``` | See Define an index | | --- | --- | --- | ### [](#exact-match-search)Exact match search ```fql // Runs an unindexed query. Customer.where(.email == "alice.appleseed@example.com") ``` For better performance on large datasets, use an index with a term to run an [exact match search](../../../data-model/indexes/#terms). Define the index in the collection schema: ```fsl collection Customer { ... // Defines the `byEmail()` index for the `Customer` // collection. index byEmail { // Includes the `email` field as an index term. terms [.email] values [.name, .email] } } ``` You call an index as a method on its collection: ```fql // Uses the `Customer` collection's `byEmail()` index // to run an exact match search on an `email` field value. Customer.byEmail("alice.appleseed@example.com") ``` | See Run an exact match search | | --- | --- | --- | ### [](#sort-collection-documents)Sort collection documents ```fql // Runs an unindexed query. // Sorts `Product` collection documents by: // - `price` (ascending), then ... // - `name` (ascending), then ... // - `description` (ascending), then ... // - `stock` (ascending). Product.all().order(.price, .name, .description, .stock) ``` For better performance on large datasets, use an index with values to [sort collection documents](../../../data-model/indexes/#sort-documents). Define the index in the collection schema: ```fsl collection Product { ... // Defines the `sortedByPriceLowToHigh()` index. index sortedByPriceLowToHigh { // `values` are document fields for sorting and range searches. values [.price, .name, .description, .stock] } } ``` Call the index in a query: ```fql // Uses the `Product` collection's `sortedByPriceLowToHigh()` index // to sort `Product` collection documents by: // - `price` (ascending), then ... // - `name` (ascending), then ... // - `description` (ascending), then ... // - `stock` (ascending). Product.sortedByPriceLowToHigh() ``` | See Sort collection documents | | --- | --- | --- | ### [](#range-search)Range search ```fql // Runs an unindexed query. // Get `Product` collection documents with a `price` between // 10_00 and 100_00 (inclusive). Product.where(.price >= 10_00 && .price <= 100_00) .order(.price, .name, .description, .stock) ``` For better performance on large datasets, use an index with values to run [range searches](../../../data-model/indexes/#range-search) on collection documents, Define the index in the collection schema: ```fsl collection Product { ... // Defines the `sortedByPriceLowToHigh()` index. index sortedByPriceLowToHigh { // `values` are document fields for sorting and range searches. values [.price, .name, .description, .stock] } } ``` Call the index in a query: ```fql // Get `Product` collection documents with a `price` between // 10_00 and 100_00 (inclusive). Product.sortedByPriceLowToHigh({ from: 10_00, to: 100_00 }) ``` | See Run a range search | | --- | --- | --- | ### [](#projection)Projection ```fql // Projects the `name`, `description`, and `price` fields. Product.sortedByPriceLowToHigh() { name, description, price } ``` ``` { data: [ { name: "single lime", description: "Conventional, 1 ct", price: 35 }, { name: "cilantro", description: "Organic, 1 bunch", price: 149 }, ... ] } ``` | Reference: Projection and field aliasing | | --- | --- | --- | ### [](#paginate-results)Paginate results Fauna automatically paginates result Sets with 16 or more elements. When a query returns paginated results, Fauna materializes a subset of the Set with an `after` pagination cursor: ```fql // Uses the `Product` collection's `sortedByPriceLowToHigh()` index to // return all `Product` collection documents. // The collection contains more than 16 documents. Product.sortedByPriceLowToHigh() ``` ``` { // The result Set contains 16 elements. data: [ { id: "555", coll: Product, ts: Time("2099-07-30T15:57:03.730Z"), name: "single lime", description: "Conventional, 1 ct", price: 35, stock: 1000, category: Category("789") }, { id: "888", coll: Product, ts: Time("2099-07-30T15:57:03.730Z"), name: "cilantro", description: "Organic, 1 bunch", price: 149, stock: 100, category: Category("789") } ], // Use the `after` cursor to get the next page of results. after: "hdW..." } ``` To get the next page of results, pass the `after` cursor to [`Set.paginate()`](../../../../reference/fql-api/set/static-paginate/): ```fql Set.paginate("hdW...") ``` The Fauna client drivers also include methods for automatically iterating through pages. See: * [JavaScript driver docs](../../../../build/drivers/js-client/#pagination) * [Python driver docs](../../../../build/drivers/py-client/#pagination) * [Go driver docs](../../../../build/drivers/go-client/#pagination) * [.NET/C# driver docs](../../../../build/drivers/dotnet-client/#pagination) * [JVM driver docs](../../../../build/drivers/jvm-client/#pagination) ## [](#document-relationships)Document relationships ### [](#create-a-document-relationship)Create a document relationship To create a document relationship, include a document reference as a field value: ```fql // References a `Category` collection document. let produce = Category.byName("produce").first() // Creates a `Product` collection document. Product.create({ name: "lemons", description: "Organic, 16 ct", price: 2_49, stock: 200, // Adds the previous `Category` document reference as // a `category` field value. category: produce }) ``` | See Create a document relationship | | --- | --- | --- | ### [](#resolve-document-relationships)Resolve document relationships You can project a field that contains a document to dynamically resolve the document reference: ```fql let produce = Category.byName("produce").first() // Projects the `name`, `description`, `price`, // and `category` fields. Product.byCategory(produce) { name, description, price, category } ``` ``` { data: [ { name: "avocados", description: "Conventional Hass, 4ct bag", price: 399, // Resolves the `Category` collection document in // the `category` field. category: { id: "789", coll: Category, ts: Time("2099-07-29T21:18:48.680Z"), products: "hdW...", name: "produce", description: "Fresh Produce" } }, { name: "single lime", description: "Conventional, 1 ct", price: 35, category: { id: "789", coll: Category, ts: Time("2099-07-29T21:18:48.680Z"), products: "hdW...", name: "produce", description: "Fresh Produce" } }, ... ] } ``` | See Resolve document relationships with projection | | --- | --- | --- | ### [](#delete-document-relationships)Delete document relationships To delete a document relationship, remove the field that contains the document reference. Removing the field does not delete the referenced document. For example: ```fql // Updates a `Product` collection document. Product.byId("111")?.update({ // Removes the `category` field, which contains a // reference to a `Category` collection document. // Removing the `category` field does not delete // the `Category` document. category: null }) ``` ### [](#dangling-references)Dangling references Deleting a document does not remove its inbound document references. Documents may contain references to documents that don’t exist. These are called dangling references. For example: ```fql // Gets a `Product` collection document. // Use projection to return `name`, `description`, and `category` fields. Product.byId("111") { name, description, // The `category` field contains a reference to a `Category` collection document. category } ``` ``` { name: "cups", description: "Translucent 9 Oz, 100 ct", // If the referenced `Category` collection document doesn't exist, // the projection returns a NullDoc. category: Category("123") /* not found */ } ``` ### [](#perform-a-cascading-delete)Perform a cascading delete A cascading delete is an operation where deleting a document in one collection automatically deletes related documents in other collections. Fauna doesn’t provide automatic cascading deletes for user-defined collections. Instead, you can use an index and [`set.forEach()`](../../../../reference/fql-api/set/foreach/) to iterate through a document’s relationships. In the following example, you’ll delete a `Category` collection document and any `Product` documents that reference the category. 1. Define an index as part of a [collection schema](../../../schema/): ```fsl collection Product { ... category: Ref ... // Defines the `byCategory()` index. // Use the index to get `Product` collection // documents by `category` value. In this case, // `category` contains a reference to a `Category` collection document. index byCategory { terms [.category] } } ``` 2. Use the index and [`set.forEach()`](../../../../reference/fql-api/set/foreach/) to delete the category and any related products: ```fql // Gets a `Category` collection document. let category = Category.byId("333") // Gets `Product` collection documents that // contain the `Category` document in the `category` field. let products = Product.byCategory(category) // Deletes the `Category` collection document. category?.delete() // Deletes `Product` collection documents that // contain the `Category` document in the `category` field. products.forEach(.delete()) // Returns `null` ``` ## [](#child-databases)Child databases ### [](#create-a-child-database)Create a child database ```fql // Creates the `childDB` child database. Database.create({ name: "childDB", // Enables typechecking for the database. typechecked: true }) ``` | Reference: Database.create() | | --- | --- | --- | ### [](#get-a-child-database)Get a child database ```fql // Gets the `childDB` child database. Database.byName("childDB") ``` | Reference: Database.byName() | | --- | --- | --- | ### [](#update-a-child-database)Update a child database ```fql // Updates the `childDB` child database's // `typechecked` field. Database.byName("childDB")?.update({typechecked: false}) ``` | Reference: database.update() | | --- | --- | --- | ### [](#delete-a-child-database)Delete a child database ```fql // Deletes the `childDB` child database. Database.byName("childDB")?.delete() ``` | Reference: database.delete() | | --- | --- | --- | # FQL syntax quick look This gives you a quick look at the Fauna Query Language (FQL) syntax. FQL is similar to JavaScript with influences from TypeScript and GraphQL, differing from those languages in that it is optimized for database operations. ## [](#basic-syntax)Basic syntax ```fql // Single-line comments start with double-slash. /* Block comments start with slash-asterisk and end with asterisk-slash. */ // Statements don't have to be terminated by ; ... (1 + 3) * 2 // ... but can be. (1 + 3) * 2; ///////////////////////////////////////////// // Numbers, Strings, and Operators // FQL has integer, decimal, and exponential values stored as // Int, Long, or Double types, which are all Number types. // An Int is a signed 32-bit integer type. // A Long is a signed 64-bit integer type. // Doubles are double-precision, 64-bit binary type, IEEE 754-2019. 3 // 3 1.5 // 1.5 3.14e5 // 314000.0 // Some basic arithmetic works as you'd expect. 1 + 1 // 2 0.1 + 0.2 // 0.30000000000000004 8 - 1 // 7 10 * 2 // 20 35 / 5 // 7 // Including uneven division. 5 / 2 // 2 // Precedence is enforced with parentheses. (1 + 3) * 2 // 8 // There's also a boolean type. true false // Strings are created with ' or ". 'abc' // "abc" "Hello, world" // "Hello, world" // Negation uses the ! symbol !true // false !false // true // Equality is == 1 == 1 // true 2 == 1 // false // Inequality is != 1 != 1 // false 2 != 1 // true // More comparisons 1 < 10 // true 1 > 10 // false 2 <= 2 // true 2 >= 2 // true // Strings are concatenated with + "Hello " + "world!" // "Hello world!" // and are compared with < and > "a" < "b" // true // Type coercion isn't performed for comparisons with double equals... "5" == 5 // false // You can access characters in a string with at() built-in string method. "This is a string".at(0) // "T" // ...or use an index. "Hello world"[0] // "H" // "length" is a property so don't use (). "Hello".length // 5 // There's also "null". null; // used to indicate a deliberate non-value // false, null, 0, and "" are falsy; everything else is truthy. ///////////////////////////////////////////// // Arrays, and Objects // Arrays are ordered lists containing values, of any type. let myArray = ["Hello", 45, true] myArray // ["Hello", 45, true] // Their members can be accessed using the square-brackets subscript syntax. // Array indices start at zero. You can also use the `at()` built-in method. myArray[1] // 45 myArray.at(1) // 45 // Arrays are of variable length. myArray.length // 3 // Accessing an Array index greater than or equal to the Array length: myArray[3] // results in an error. // Create an Array from elements in the range index 1 (include) to // index 4 (exclude). myArray.slice(1, 4) // [45, true] // FQL objects are equivalent to "dictionaries" or "maps" in other // languages: an unordered collection of key:value pairs. You can use // the dot syntax provided the key is a valid identifier. let myObj = {key1: "Hello", key2: "World"} myObj.key1 // "Hello" // Keys are strings but quotes aren't required if they're a valid // JavaScript identifier. Values can be any type. let myObj = {myKey: "myValue", "myOtherKey": 4} // Object attributes can also be accessed using the subscript syntax. myObj.myKey // "myValue" myObj.myOtherKey // 4 // If you try to access a value not yet set, you'll get an error. myObj.myThirdKey // results in an error. ///////////////////////////////////////////// // Variables // Use the "let" keyword to declare variables in a lexical scope and // assign a value to the variable. FQL is dynamically typed, so you don't // need to specify type. Assignment uses a single = character. Also, "let" // can't be the last statement, because it isn't an expression. let someVar = 5 someVar // 5 // A variable in the same scope can be assigned a new value: let someVar = 5 let someVar = 6 someVar // 6 // You can declare only one variable in the same `let` statement. // You can use "let" with an "if ... else" statement to // conditionally assign a variable value. let x = "cat" let y = if (x == "cat") { "Meow" } else if (x == "dog") { "Woof" } else { "Call the exterminator" } y // "Meow" ///////////////////////////////////////////// // Control structures, logic // The `if ... else` structure works as you'd expect. let count = 1 if (count == 3) { // evaluated if count is 3 } else if (count == 4) { // evaluated if count is 4 } else { // evaluated if not 3 or 4 } // `&&` is logical AND, `||` is logical OR let house = {size: "big", color: "blue"} if (house.size == "big" && house.color == "blue") { "big blue house" } if (house.color == "red" || house.color == "blue") { "red or blue" } ///////////////////////////////////////////// // Block scope // A block is defined with `{ }` and variables are scoped to the block. // Variables outside of the block are global. // The last statement in a block must be an expression. let greeting = "hi" { let greeting = "hello" greeting } // "hello" let greeting = "hi" { let greeting = "hello" greeting } greeting // "hi" ///////////////////////////////////////////// // Anonymous functions // FQL anonymous functions are declared using the short-form // arrow syntax. An anonymous function can't be called before the definition. (x) => { let greeting = "hello" greeting } // Objects can contain functions. let myFunc = { (x) => { let double = x + x double } } myFunc(3) // 6 // Some built-in methods accept single-argument functions. Customer.all().where(c => c.address.zipCode == "20002") // Which is equivalent to: let myFunc = { (c) => { c.address.zipCode == "20002" } } Customer.all().where(myFunc) ``` # FQL cheat sheet This page provides a quick reference of FQL properties and methods, grouped by functionality. | Access providerAccessProvider.all()Get a Set of all access providers.AccessProvider.byName()Get an access provider by its name.AccessProvider.create()Create an access provider.AccessProvider.firstWhere()Get the first access provider that matches a provided predicate.AccessProvider.toString()Get "AccessProvider" as a String.AccessProvider.where()Get a Set of access providers that match a provided predicate.accessProvider.delete()Delete an access provider.accessProvider.exists()Test if an access provider exists.accessProvider.replace()Replace an access provider.accessProvider.update()Update an access provider.ArrayArray.sequence()Create an ordered Array of Numbers given start and end values.array.lengthThe number of elements in the Array.array.aggregate()Aggregate all elements of an Array.array.any()Test if any element of an Array matches a provided predicate.array.append()Append a provided element to an Array.array.at()Get the Array element at a provided index.array.concat()Concatenate two Arrays.array.distinct()Get the unique elements of an Array.array.drop()Drop the first N elements of an Array.array.entries()Add the index to each element of an Array.array.every()Test if every element of an Array matches a provided predicate.array.filter()Filter an Array using a provided predicate.array.first()Get the first element of an Array.array.firstWhere()Get the first element of an Array that matches a provided predicate.array.flatMap()Apply a provided function to each Array element and flatten the resulting Array by one level.array.flatten()Flatten an Array by one level.array.fold()Reduce the Array to a single, accumulated value by applying a provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value.array.foldRight()Reduce an Array to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value.array.forEach()Run a provided function on each element of an Array. 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 provided 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 provided predicate.array.lastWhere()Get the last element of an Array that matches a provided predicate.array.map()Apply a provided function to each element of an Array. 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 provided 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 provided 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()Get a subset of an Array's elements based on provided 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 elements of an Array that match a provided predicate.BytesBytes()Convert a Base64-encoded string to an FQL Bytes value.Bytes.fromBase64()Convert a Base64-encoded string to an FQL Bytes value.bytes.toBase64()Convert an FQL Bytes value to a Base64-encoded string.bytes.toString()Convert an FQL Bytes value to a Base64-encoded string.Collectioncollection.definitionGet a collection definition, represented as a Collection document with the CollectionDef type.Collection()Access a collection by its name.Collection.all()Get a Set of all collection definitions.Collection.byName()Get a collection definitions by its name.Collection.create()Create a collection.Collection.firstWhere()Get the first collection definition that matches a provided predicate.Collection.toString()Get "Collection" as a String.Collection.where()Get a Set of collection definitions that match a provided predicate.collectionDef.delete()Delete a collection.collectionDef.exists()Test if a collection exists.collectionDef.replace()Replaces a collection definition.collectionDef.update()Update a collection definition.collection.all()Get a Set of all documents in a collection.collection.byId()Get a collection document by its document id.collection.create()Create a collection document.collection.firstWhere()Get the first collection document that matches a provided predicate.collection.indexName()Call an index as a method to get a Set of matching collection documents.collection.where()Get a Set of collection documents that match a provided predicate.CredentialCredential.all()Get a Set of all credentials.Credential.byDocument()Get a credential by its identity document.Credential.byId()Get a credential by its document id.Credential.create()Create a credential.Credential.firstWhere()Get the first credential that matches a provided predicate.Credential.toString()Get "Credential" as a String.Credential.where()Get a Set of credentials that match a provided 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.DatabaseDatabase.all()Get a Set of all child databases nested directly under the database.Database.byName()Get a child database by its name.Database.create()Create a child database.Database.firstWhere()Get the first child database document that matches a provided predicate.Database.toString()Get "Database" as a String.Database.where()Get a Set of child databases that match a provided predicate.database.delete()Deletes 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.DatedayOfMonthGet the day of the month from a Date.dayOfWeekGet the day of the week from a Date.dayOfYearGet the day of the year from a Date.monthGet the month of a Date.yearGet the year of a Date.Date()Construct a Date from a ISO 8601 date String.Date.fromString()Construct a Date from a date String.Date.today()Get the current UTC Date.date.add()Add number of days to a Date.date.difference()Get the difference between two Dates.date.subtract()Subtract number of days from a Date.date.toString()Convert a Date to a String.Documentdocument.delete()Delete a collection document.document.exists()Test if a collection document exists.document.replace()Replace all fields in a collection document.document.update()Update a collection document's fields.EventSourceeventSource.map()Apply an anonymous function to each element of an event source's tracked Set.eventSource.toString()Get "[event source]" as a string.eventSource.where()Create an event source that emits events for a subset of another event source’s tracked Set.Functionfunction.definitionGet or update a user-defined function (UDF)'s definition, represented as a Function document.Function()Call a user-defined function (UDF) by its name.Function.all()Get a Set of all user-defined functions (UDFs).Function.byName()Get a user-defined function (UDF) by its name.Function.create()Create a user-defined function (UDF).Function.firstWhere()Get the first user-defined function (UDF) that matches a provided predicate.Function.toString()Get "Function" as a String.Function.where()Get a Set of user-defined functions (UDFs) that match a provided predicate.functionDef.delete()Delete a user-defined function (UDF).functionDef.exists()Test if a user-defined function (UDF) exists.functionDef.replace()Replace a user-defined function (UDF).functionDef.update()Update a user-defined function (UDF).Global functionsabort()End the current query and return an abort error with a user-defined abort value.dbg()Output a debug message in the query summary and return the message in the query results.ID()Create a valid IDlog()Output a log message in the query summary and return null.newId()Get a unique string-encoded 64-bit integer.KeyKey.all()Get a Set of all keys.Key.byId()Get a key by its document id.Key.create()Create a key.Key.firstWhere()Get the first key that matches a provided predicate.Key.toString()Get "Key" as a String.Key.where()Get a Set of keys that match a provided predicate.key.delete()Delete a key.key.exists()Test if a key exists.key.replace()Replace a key.key.update()Update a key. | AccessProvider.all() | Get a Set of all access providers. | AccessProvider.byName() | Get an access provider by its name. | AccessProvider.create() | Create an access provider. | AccessProvider.firstWhere() | Get the first access provider that matches a provided predicate. | AccessProvider.toString() | Get "AccessProvider" as a String. | AccessProvider.where() | Get a Set of access providers that match a provided predicate. | accessProvider.delete() | Delete an access provider. | accessProvider.exists() | Test if an access provider exists. | accessProvider.replace() | Replace an access provider. | accessProvider.update() | Update an access provider. | Array.sequence() | Create an ordered Array of Numbers given start and end values. | array.length | The number of elements in the Array. | array.aggregate() | Aggregate all elements of an Array. | array.any() | Test if any element of an Array matches a provided predicate. | array.append() | Append a provided element to an Array. | array.at() | Get the Array element at a provided index. | array.concat() | Concatenate two Arrays. | array.distinct() | Get the unique elements of an Array. | array.drop() | Drop the first N elements of an Array. | array.entries() | Add the index to each element of an Array. | array.every() | Test if every element of an Array matches a provided predicate. | array.filter() | Filter an Array using a provided predicate. | array.first() | Get the first element of an Array. | array.firstWhere() | Get the first element of an Array that matches a provided predicate. | array.flatMap() | Apply a provided function to each Array element and flatten the resulting Array by one level. | array.flatten() | Flatten an Array by one level. | array.fold() | Reduce the Array to a single, accumulated value by applying a provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value. | array.foldRight() | Reduce an Array to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value. | array.forEach() | Run a provided function on each element of an Array. 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 provided 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 provided predicate. | array.lastWhere() | Get the last element of an Array that matches a provided predicate. | array.map() | Apply a provided function to each element of an Array. 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 provided 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 provided 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() | Get a subset of an Array's elements based on provided 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 elements of an Array that match a provided predicate. | Bytes() | Convert a Base64-encoded string to an FQL Bytes value. | Bytes.fromBase64() | Convert a Base64-encoded string to an FQL Bytes value. | bytes.toBase64() | Convert an FQL Bytes value to a Base64-encoded string. | bytes.toString() | Convert an FQL Bytes value to a Base64-encoded string. | collection.definition | Get a collection definition, represented as a Collection document with the CollectionDef type. | Collection() | Access a collection by its name. | Collection.all() | Get a Set of all collection definitions. | Collection.byName() | Get a collection definitions by its name. | Collection.create() | Create a collection. | Collection.firstWhere() | Get the first collection definition that matches a provided predicate. | Collection.toString() | Get "Collection" as a String. | Collection.where() | Get a Set of collection definitions that match a provided predicate. | collectionDef.delete() | Delete a collection. | collectionDef.exists() | Test if a collection exists. | collectionDef.replace() | Replaces a collection definition. | collectionDef.update() | Update a collection definition. | collection.all() | Get a Set of all documents in a collection. | collection.byId() | Get a collection document by its document id. | collection.create() | Create a collection document. | collection.firstWhere() | Get the first collection document that matches a provided predicate. | collection.indexName() | Call an index as a method to get a Set of matching collection documents. | collection.where() | Get a Set of collection documents that match a provided predicate. | Credential.all() | Get a Set of all credentials. | Credential.byDocument() | Get a credential by its identity document. | Credential.byId() | Get a credential by its document id. | Credential.create() | Create a credential. | Credential.firstWhere() | Get the first credential that matches a provided predicate. | Credential.toString() | Get "Credential" as a String. | Credential.where() | Get a Set of credentials that match a provided 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.all() | Get a Set of all child databases nested directly under the database. | Database.byName() | Get a child database by its name. | Database.create() | Create a child database. | Database.firstWhere() | Get the first child database document that matches a provided predicate. | Database.toString() | Get "Database" as a String. | Database.where() | Get a Set of child databases that match a provided predicate. | database.delete() | Deletes 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. | dayOfMonth | Get the day of the month from a Date. | dayOfWeek | Get the day of the week from a Date. | dayOfYear | Get the day of the year from a Date. | month | Get the month of a Date. | year | Get the year of a Date. | Date() | Construct a Date from a ISO 8601 date String. | Date.fromString() | Construct a Date from a date String. | Date.today() | Get the current UTC Date. | date.add() | Add number of days to a Date. | date.difference() | Get the difference between two Dates. | date.subtract() | Subtract number of days from a Date. | date.toString() | Convert a Date to a String. | document.delete() | Delete a collection document. | document.exists() | Test if a collection document exists. | document.replace() | Replace all fields in a collection document. | document.update() | Update a collection document's fields. | eventSource.map() | Apply an anonymous function to each element of an event source's tracked Set. | eventSource.toString() | Get "[event source]" as a string. | eventSource.where() | Create an event source that emits events for a subset of another event source’s tracked Set. | function.definition | Get or update a user-defined function (UDF)'s definition, represented as a Function document. | Function() | Call a user-defined function (UDF) by its name. | Function.all() | Get a Set of all user-defined functions (UDFs). | Function.byName() | Get a user-defined function (UDF) by its name. | Function.create() | Create a user-defined function (UDF). | Function.firstWhere() | Get the first user-defined function (UDF) that matches a provided predicate. | Function.toString() | Get "Function" as a String. | Function.where() | Get a Set of user-defined functions (UDFs) that match a provided predicate. | functionDef.delete() | Delete a user-defined function (UDF). | functionDef.exists() | Test if a user-defined function (UDF) exists. | functionDef.replace() | Replace a user-defined function (UDF). | functionDef.update() | Update a user-defined function (UDF). | abort() | End the current query and return an abort error with a user-defined abort value. | dbg() | Output a debug message in the query summary and return the message in the query results. | ID() | Create a valid ID | log() | Output a log message in the query summary and return null. | newId() | Get a unique string-encoded 64-bit integer. | Key.all() | Get a Set of all keys. | Key.byId() | Get a key by its document id. | Key.create() | Create a key. | Key.firstWhere() | Get the first key that matches a provided predicate. | Key.toString() | Get "Key" as a String. | Key.where() | Get a Set of keys that match a provided predicate. | key.delete() | Delete a key. | key.exists() | Test if a key exists. | key.replace() | Replace a key. | key.update() | Update a key. | MathMath.EGet the Euler’s number mathematical constant (℮).Math.InfinityString value representing infinity.Math.NaNValue representing Not-a-Number.Math.PIGet the mathematical constant 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 arithmetic mean of an Array or Set of Numbers.Math.min()Get the smaller of the input parameter 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 integer.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.ObjectObject.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.QueryQuery.identity()Get the identity document for the query’s authentication token.Query.isEnvProtected()Test if the queried database is in protected mode.Query.isEnvTypechecked()Test if the queried database is typechecked.Query.token()Get the Token document or JWT payload for the query’s authentication secret.RoleRole.all()Get a Set of all user-defined roles.Role.byName()Get a user-defined role by its name.Role.create()Create a user-defined role.Role.firstWhere()Get the first user-defined role matching a provided predicate.Role.toString()Get "Role" as a String.Role.where()Get a Set of user-defined roles that match a provided predicate.role.delete()Delete a user-defined role.role.exists()Test if a user-defined role exists.role.replace()Replace a user-defined role.role.update()Update a user-defined role.SchemaFQL.Schema.defForIdentifier()Returns the definition for a user-defined collection or user-defined function (UDF) using the same rules as top-level identifier lookups.SetSet.paginate()Get a page of paginated results using an after cursor.Set.sequence()Create an ordered Set of Numbers given start and end values.Set.single()Create a Set containing a single provided element.set.aggregate()Aggregate all elements of a Set.set.any()Test if any element of a Set matches a provided predicate.set.changesOn()Create an event source that tracks changes to specified document fields in a supported Set.set.concat()Concatenate two Sets.set.count()Get the number of elements in a Set.set.distinct()Get the unique elements of a Set.set.drop()Drop the first N elements of a Set.set.eventsOn()Create an event source that tracks changes to specified document fields in a supported Set.set.eventSource()Create an event source that tracks changes to documents in a supported Set.set.every()Test if every element of a Set matches a provided predicate.set.first()Get the first element of a Set.set.firstWhere()Get the first element of a Set that matches a provided predicate.set.flatMap()Apply a provided 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 provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value.set.foldRight()Reduce a Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value.set.forEach()Run a provided function on each element of a Set. 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 element of a Set that matches a provided predicate.set.map()Apply a provided function to each element of a Set. Can’t perform writes.set.nonEmpty()Test if a Set is not empty.set.order()Sort a Set's elements.set.pageSize()Set the maximum elements per page in paginated results.set.paginate()Convert a Set to an Object with pagination.set.reduce()Reduce a Set to a single, accumulated value by applying a provided 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 provided 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()Create an event source that tracks changes to documents in a supported Set.set.toString()Return the string "[set]".set.where()Get the elements of a Set that match a provided predicate.Stringstring.lengthGet a String's length.string.at()Get the character at a specified index of a String.string.casefold()Convert a String to lower case using a specified format.string.concat()Concatenate two Strings.string.endsWith()Test if a String ends with a provided suffix.string.includes()Test if a String includes a provided substring.string.includesRegex()Test if a String contains a substring that matches a provided regular expression.string.indexOf()Get the index of the first matching substring within a String.string.indexOfRegex()Get the index of the first substring matching a provided regular expression within a String.string.insert()Insert a substring into a String at a specified index.string.lastIndexOf()Get the index of the last matching substring within a String.string.matches()Get the substrings in a String that match a provided regular expression.string.matchIndexes()Get the indexes and substrings in a String that match a provided 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 a specified number of occurrences of a substring in a String.string.replaceAll()Replace all occurrences of a substring in a String.string.replaceAllRegex()Replace all occurrences of substrings matching a regular expression in a String.string.replaceRegex()Replace a specified number of occurrences of substrings matching a regular expression in a String.string.slice()Get the substring between two indexes of a String.string.split()Split a String at a provided separator.string.splitAt()Split a String at a provided index.string.splitRegex()Split a String using a provided regular expression.string.startsWith()Test if a String starts with a provided prefix.string.toLowerCase()Convert a String to lower case.string.toString()Get a String representation of the value.string.toUpperCase()Convert a String to upper case.TimedayOfMonthGet the day of the month from a Time.dayOfWeekGet the day of the week from a Time.dayOfYearGet the day of the year from a Time.hourGet the hour of a Time.minuteGet the minute of a Time.monthGet the month of a Time.secondGet the second of a Time.yearGet the year of a Time.Time()Construct a Time from an ISO 8601 timestamp String.Time.epoch()Convert a Unix epoch timestamp to a Time.Time.fromString()Construct a Time from an ISO 8601 timestamp String.Time.now()Get the current UTC Time.time.add()Add a time interval to a Time.time.difference()Get the difference between two Times.time.subtract()Subtract a time interval from a Time.time.toMicros()Convert a Time to a Unix epoch timestamp in microseconds.time.toMillis()Convert a Time to a Unix epoch timestamp in milliseconds.time.toSeconds()Convert a Time to a Unix epoch timestamp in seconds.time.toString()Convert a Time to a String.TokenToken.all()Get a Set of all tokens.Token.byDocument()Get a token by its identity document.Token.byId()Get a token by its document id.Token.create()Create a token without a credential or related password.Token.firstWhere()Get the first token that matches a provided predicate.Token.toString()Get "Token" as a String.Token.where()Get a Set of tokens that match a provided predicate.token.delete()Delete a token.token.exists()Test if a token exists.token.replace()Replace a token.token.update()Update a token.Transaction TimeTransactionTime()Get the query transaction time.TransactionTime.toString()Get "[transaction time]" as a String. | Math.E | Get the Euler’s number mathematical constant (℮). | Math.Infinity | String value representing infinity. | Math.NaN | Value representing Not-a-Number. | Math.PI | Get the mathematical constant 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 arithmetic mean of an Array or Set of Numbers. | Math.min() | Get the smaller of the input parameter 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 integer. | 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.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.identity() | Get the identity document for the query’s authentication token. | Query.isEnvProtected() | Test if the queried database is in protected mode. | Query.isEnvTypechecked() | Test if the queried database is typechecked. | Query.token() | Get the Token document or JWT payload for the query’s authentication secret. | Role.all() | Get a Set of all user-defined roles. | Role.byName() | Get a user-defined role by its name. | Role.create() | Create a user-defined role. | Role.firstWhere() | Get the first user-defined role matching a provided predicate. | Role.toString() | Get "Role" as a String. | Role.where() | Get a Set of user-defined roles that match a provided predicate. | role.delete() | Delete a user-defined role. | role.exists() | Test if a user-defined role exists. | role.replace() | Replace a user-defined role. | role.update() | Update a user-defined role. | FQL.Schema.defForIdentifier() | Returns the definition for a user-defined collection or user-defined function (UDF) using the same rules as top-level identifier lookups. | Set.paginate() | Get a page of paginated results using an after cursor. | Set.sequence() | Create an ordered Set of Numbers given start and end values. | Set.single() | Create a Set containing a single provided element. | set.aggregate() | Aggregate all elements of a Set. | set.any() | Test if any element of a Set matches a provided predicate. | set.changesOn() | Create an event source that tracks changes to specified document fields in a supported Set. | set.concat() | Concatenate two Sets. | set.count() | Get the number of elements in a Set. | set.distinct() | Get the unique elements of a Set. | set.drop() | Drop the first N elements of a Set. | set.eventsOn() | Create an event source that tracks changes to specified document fields in a supported Set. | set.eventSource() | Create an event source that tracks changes to documents in a supported Set. | set.every() | Test if every element of a Set matches a provided predicate. | set.first() | Get the first element of a Set. | set.firstWhere() | Get the first element of a Set that matches a provided predicate. | set.flatMap() | Apply a provided 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 provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value. | set.foldRight() | Reduce a Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value. | set.forEach() | Run a provided function on each element of a Set. 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 element of a Set that matches a provided predicate. | set.map() | Apply a provided function to each element of a Set. Can’t perform writes. | set.nonEmpty() | Test if a Set is not empty. | set.order() | Sort a Set's elements. | set.pageSize() | Set the maximum elements per page in paginated results. | set.paginate() | Convert a Set to an Object with pagination. | set.reduce() | Reduce a Set to a single, accumulated value by applying a provided 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 provided 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() | Create an event source that tracks changes to documents in a supported Set. | set.toString() | Return the string "[set]". | set.where() | Get the elements of a Set that match a provided predicate. | string.length | Get a String's length. | string.at() | Get the character at a specified index of a String. | string.casefold() | Convert a String to lower case using a specified format. | string.concat() | Concatenate two Strings. | string.endsWith() | Test if a String ends with a provided suffix. | string.includes() | Test if a String includes a provided substring. | string.includesRegex() | Test if a String contains a substring that matches a provided regular expression. | string.indexOf() | Get the index of the first matching substring within a String. | string.indexOfRegex() | Get the index of the first substring matching a provided regular expression within a String. | string.insert() | Insert a substring into a String at a specified index. | string.lastIndexOf() | Get the index of the last matching substring within a String. | string.matches() | Get the substrings in a String that match a provided regular expression. | string.matchIndexes() | Get the indexes and substrings in a String that match a provided 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 a specified number of occurrences of a substring in a String. | string.replaceAll() | Replace all occurrences of a substring in a String. | string.replaceAllRegex() | Replace all occurrences of substrings matching a regular expression in a String. | string.replaceRegex() | Replace a specified number of occurrences of substrings matching a regular expression in a String. | string.slice() | Get the substring between two indexes of a String. | string.split() | Split a String at a provided separator. | string.splitAt() | Split a String at a provided index. | string.splitRegex() | Split a String using a provided regular expression. | string.startsWith() | Test if a String starts with a provided prefix. | string.toLowerCase() | Convert a String to lower case. | string.toString() | Get a String representation of the value. | string.toUpperCase() | Convert a String to upper case. | dayOfMonth | Get the day of the month from a Time. | dayOfWeek | Get the day of the week from a Time. | dayOfYear | Get the day of the year from a Time. | hour | Get the hour of a Time. | minute | Get the minute of a Time. | month | Get the month of a Time. | second | Get the second of a Time. | year | Get the year of a Time. | Time() | Construct a Time from an ISO 8601 timestamp String. | Time.epoch() | Convert a Unix epoch timestamp to a Time. | Time.fromString() | Construct a Time from an ISO 8601 timestamp String. | Time.now() | Get the current UTC Time. | time.add() | Add a time interval to a Time. | time.difference() | Get the difference between two Times. | time.subtract() | Subtract a time interval from a Time. | time.toMicros() | Convert a Time to a Unix epoch timestamp in microseconds. | time.toMillis() | Convert a Time to a Unix epoch timestamp in milliseconds. | time.toSeconds() | Convert a Time to a Unix epoch timestamp in seconds. | time.toString() | Convert a Time to a String. | Token.all() | Get a Set of all tokens. | Token.byDocument() | Get a token by its identity document. | Token.byId() | Get a token by its document id. | Token.create() | Create a token without a credential or related password. | Token.firstWhere() | Get the first token that matches a provided predicate. | Token.toString() | Get "Token" as a String. | Token.where() | Get a Set of tokens that match a provided predicate. | token.delete() | Delete a token. | token.exists() | Test if a token exists. | token.replace() | Replace a token. | token.update() | Update a token. | TransactionTime() | Get the query transaction time. | TransactionTime.toString() | Get "[transaction time]" as a String. | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | AccessProvider.all() | Get a Set of all access providers. | | AccessProvider.byName() | Get an access provider by its name. | | AccessProvider.create() | Create an access provider. | | AccessProvider.firstWhere() | Get the first access provider that matches a provided predicate. | | AccessProvider.toString() | Get "AccessProvider" as a String. | | AccessProvider.where() | Get a Set of access providers that match a provided predicate. | | accessProvider.delete() | Delete an access provider. | | accessProvider.exists() | Test if an access provider exists. | | accessProvider.replace() | Replace an access provider. | | accessProvider.update() | Update an access provider. | | Array.sequence() | Create an ordered Array of Numbers given start and end values. | | array.length | The number of elements in the Array. | | array.aggregate() | Aggregate all elements of an Array. | | array.any() | Test if any element of an Array matches a provided predicate. | | array.append() | Append a provided element to an Array. | | array.at() | Get the Array element at a provided index. | | array.concat() | Concatenate two Arrays. | | array.distinct() | Get the unique elements of an Array. | | array.drop() | Drop the first N elements of an Array. | | array.entries() | Add the index to each element of an Array. | | array.every() | Test if every element of an Array matches a provided predicate. | | array.filter() | Filter an Array using a provided predicate. | | array.first() | Get the first element of an Array. | | array.firstWhere() | Get the first element of an Array that matches a provided predicate. | | array.flatMap() | Apply a provided function to each Array element and flatten the resulting Array by one level. | | array.flatten() | Flatten an Array by one level. | | array.fold() | Reduce the Array to a single, accumulated value by applying a provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value. | | array.foldRight() | Reduce an Array to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value. | | array.forEach() | Run a provided function on each element of an Array. 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 provided 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 provided predicate. | | array.lastWhere() | Get the last element of an Array that matches a provided predicate. | | array.map() | Apply a provided function to each element of an Array. 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 provided 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 provided 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() | Get a subset of an Array's elements based on provided 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 elements of an Array that match a provided predicate. | | Bytes() | Convert a Base64-encoded string to an FQL Bytes value. | | Bytes.fromBase64() | Convert a Base64-encoded string to an FQL Bytes value. | | bytes.toBase64() | Convert an FQL Bytes value to a Base64-encoded string. | | bytes.toString() | Convert an FQL Bytes value to a Base64-encoded string. | | collection.definition | Get a collection definition, represented as a Collection document with the CollectionDef type. | | Collection() | Access a collection by its name. | | Collection.all() | Get a Set of all collection definitions. | | Collection.byName() | Get a collection definitions by its name. | | Collection.create() | Create a collection. | | Collection.firstWhere() | Get the first collection definition that matches a provided predicate. | | Collection.toString() | Get "Collection" as a String. | | Collection.where() | Get a Set of collection definitions that match a provided predicate. | | collectionDef.delete() | Delete a collection. | | collectionDef.exists() | Test if a collection exists. | | collectionDef.replace() | Replaces a collection definition. | | collectionDef.update() | Update a collection definition. | | collection.all() | Get a Set of all documents in a collection. | | collection.byId() | Get a collection document by its document id. | | collection.create() | Create a collection document. | | collection.firstWhere() | Get the first collection document that matches a provided predicate. | | collection.indexName() | Call an index as a method to get a Set of matching collection documents. | | collection.where() | Get a Set of collection documents that match a provided predicate. | | Credential.all() | Get a Set of all credentials. | | Credential.byDocument() | Get a credential by its identity document. | | Credential.byId() | Get a credential by its document id. | | Credential.create() | Create a credential. | | Credential.firstWhere() | Get the first credential that matches a provided predicate. | | Credential.toString() | Get "Credential" as a String. | | Credential.where() | Get a Set of credentials that match a provided 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.all() | Get a Set of all child databases nested directly under the database. | | Database.byName() | Get a child database by its name. | | Database.create() | Create a child database. | | Database.firstWhere() | Get the first child database document that matches a provided predicate. | | Database.toString() | Get "Database" as a String. | | Database.where() | Get a Set of child databases that match a provided predicate. | | database.delete() | Deletes 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. | | dayOfMonth | Get the day of the month from a Date. | | dayOfWeek | Get the day of the week from a Date. | | dayOfYear | Get the day of the year from a Date. | | month | Get the month of a Date. | | year | Get the year of a Date. | | Date() | Construct a Date from a ISO 8601 date String. | | Date.fromString() | Construct a Date from a date String. | | Date.today() | Get the current UTC Date. | | date.add() | Add number of days to a Date. | | date.difference() | Get the difference between two Dates. | | date.subtract() | Subtract number of days from a Date. | | date.toString() | Convert a Date to a String. | | document.delete() | Delete a collection document. | | document.exists() | Test if a collection document exists. | | document.replace() | Replace all fields in a collection document. | | document.update() | Update a collection document's fields. | | eventSource.map() | Apply an anonymous function to each element of an event source's tracked Set. | | eventSource.toString() | Get "[event source]" as a string. | | eventSource.where() | Create an event source that emits events for a subset of another event source’s tracked Set. | | function.definition | Get or update a user-defined function (UDF)'s definition, represented as a Function document. | | Function() | Call a user-defined function (UDF) by its name. | | Function.all() | Get a Set of all user-defined functions (UDFs). | | Function.byName() | Get a user-defined function (UDF) by its name. | | Function.create() | Create a user-defined function (UDF). | | Function.firstWhere() | Get the first user-defined function (UDF) that matches a provided predicate. | | Function.toString() | Get "Function" as a String. | | Function.where() | Get a Set of user-defined functions (UDFs) that match a provided predicate. | | functionDef.delete() | Delete a user-defined function (UDF). | | functionDef.exists() | Test if a user-defined function (UDF) exists. | | functionDef.replace() | Replace a user-defined function (UDF). | | functionDef.update() | Update a user-defined function (UDF). | | abort() | End the current query and return an abort error with a user-defined abort value. | | dbg() | Output a debug message in the query summary and return the message in the query results. | | ID() | Create a valid ID | | log() | Output a log message in the query summary and return null. | | newId() | Get a unique string-encoded 64-bit integer. | | Key.all() | Get a Set of all keys. | | Key.byId() | Get a key by its document id. | | Key.create() | Create a key. | | Key.firstWhere() | Get the first key that matches a provided predicate. | | Key.toString() | Get "Key" as a String. | | Key.where() | Get a Set of keys that match a provided predicate. | | key.delete() | Delete a key. | | key.exists() | Test if a key exists. | | key.replace() | Replace a key. | | key.update() | Update a key. | | Math.E | Get the Euler’s number mathematical constant (℮). | | Math.Infinity | String value representing infinity. | | Math.NaN | Value representing Not-a-Number. | | Math.PI | Get the mathematical constant 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 arithmetic mean of an Array or Set of Numbers. | | Math.min() | Get the smaller of the input parameter 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 integer. | | 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.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.identity() | Get the identity document for the query’s authentication token. | | Query.isEnvProtected() | Test if the queried database is in protected mode. | | Query.isEnvTypechecked() | Test if the queried database is typechecked. | | Query.token() | Get the Token document or JWT payload for the query’s authentication secret. | | Role.all() | Get a Set of all user-defined roles. | | Role.byName() | Get a user-defined role by its name. | | Role.create() | Create a user-defined role. | | Role.firstWhere() | Get the first user-defined role matching a provided predicate. | | Role.toString() | Get "Role" as a String. | | Role.where() | Get a Set of user-defined roles that match a provided predicate. | | role.delete() | Delete a user-defined role. | | role.exists() | Test if a user-defined role exists. | | role.replace() | Replace a user-defined role. | | role.update() | Update a user-defined role. | | FQL.Schema.defForIdentifier() | Returns the definition for a user-defined collection or user-defined function (UDF) using the same rules as top-level identifier lookups. | | Set.paginate() | Get a page of paginated results using an after cursor. | | Set.sequence() | Create an ordered Set of Numbers given start and end values. | | Set.single() | Create a Set containing a single provided element. | | set.aggregate() | Aggregate all elements of a Set. | | set.any() | Test if any element of a Set matches a provided predicate. | | set.changesOn() | Create an event source that tracks changes to specified document fields in a supported Set. | | set.concat() | Concatenate two Sets. | | set.count() | Get the number of elements in a Set. | | set.distinct() | Get the unique elements of a Set. | | set.drop() | Drop the first N elements of a Set. | | set.eventsOn() | Create an event source that tracks changes to specified document fields in a supported Set. | | set.eventSource() | Create an event source that tracks changes to documents in a supported Set. | | set.every() | Test if every element of a Set matches a provided predicate. | | set.first() | Get the first element of a Set. | | set.firstWhere() | Get the first element of a Set that matches a provided predicate. | | set.flatMap() | Apply a provided 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 provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value. | | set.foldRight() | Reduce a Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value. | | set.forEach() | Run a provided function on each element of a Set. 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 element of a Set that matches a provided predicate. | | set.map() | Apply a provided function to each element of a Set. Can’t perform writes. | | set.nonEmpty() | Test if a Set is not empty. | | set.order() | Sort a Set's elements. | | set.pageSize() | Set the maximum elements per page in paginated results. | | set.paginate() | Convert a Set to an Object with pagination. | | set.reduce() | Reduce a Set to a single, accumulated value by applying a provided 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 provided 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() | Create an event source that tracks changes to documents in a supported Set. | | set.toString() | Return the string "[set]". | | set.where() | Get the elements of a Set that match a provided predicate. | | string.length | Get a String's length. | | string.at() | Get the character at a specified index of a String. | | string.casefold() | Convert a String to lower case using a specified format. | | string.concat() | Concatenate two Strings. | | string.endsWith() | Test if a String ends with a provided suffix. | | string.includes() | Test if a String includes a provided substring. | | string.includesRegex() | Test if a String contains a substring that matches a provided regular expression. | | string.indexOf() | Get the index of the first matching substring within a String. | | string.indexOfRegex() | Get the index of the first substring matching a provided regular expression within a String. | | string.insert() | Insert a substring into a String at a specified index. | | string.lastIndexOf() | Get the index of the last matching substring within a String. | | string.matches() | Get the substrings in a String that match a provided regular expression. | | string.matchIndexes() | Get the indexes and substrings in a String that match a provided 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 a specified number of occurrences of a substring in a String. | | string.replaceAll() | Replace all occurrences of a substring in a String. | | string.replaceAllRegex() | Replace all occurrences of substrings matching a regular expression in a String. | | string.replaceRegex() | Replace a specified number of occurrences of substrings matching a regular expression in a String. | | string.slice() | Get the substring between two indexes of a String. | | string.split() | Split a String at a provided separator. | | string.splitAt() | Split a String at a provided index. | | string.splitRegex() | Split a String using a provided regular expression. | | string.startsWith() | Test if a String starts with a provided prefix. | | string.toLowerCase() | Convert a String to lower case. | | string.toString() | Get a String representation of the value. | | string.toUpperCase() | Convert a String to upper case. | | dayOfMonth | Get the day of the month from a Time. | | dayOfWeek | Get the day of the week from a Time. | | dayOfYear | Get the day of the year from a Time. | | hour | Get the hour of a Time. | | minute | Get the minute of a Time. | | month | Get the month of a Time. | | second | Get the second of a Time. | | year | Get the year of a Time. | | Time() | Construct a Time from an ISO 8601 timestamp String. | | Time.epoch() | Convert a Unix epoch timestamp to a Time. | | Time.fromString() | Construct a Time from an ISO 8601 timestamp String. | | Time.now() | Get the current UTC Time. | | time.add() | Add a time interval to a Time. | | time.difference() | Get the difference between two Times. | | time.subtract() | Subtract a time interval from a Time. | | time.toMicros() | Convert a Time to a Unix epoch timestamp in microseconds. | | time.toMillis() | Convert a Time to a Unix epoch timestamp in milliseconds. | | time.toSeconds() | Convert a Time to a Unix epoch timestamp in seconds. | | time.toString() | Convert a Time to a String. | | Token.all() | Get a Set of all tokens. | | Token.byDocument() | Get a token by its identity document. | | Token.byId() | Get a token by its document id. | | Token.create() | Create a token without a credential or related password. | | Token.firstWhere() | Get the first token that matches a provided predicate. | | Token.toString() | Get "Token" as a String. | | Token.where() | Get a Set of tokens that match a provided predicate. | | token.delete() | Delete a token. | | token.exists() | Test if a token exists. | | token.replace() | Replace a token. | | token.update() | Update a token. | | TransactionTime() | Get the query transaction time. | | TransactionTime.toString() | Get "[transaction time]" as a String. |