Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Function.all()

Signature

Function.all() => Set<FunctionDef>

Function.all(range: { from: Any } | { to: Any } | { from: Any, to: Any }) => Set<FunctionDef>

Description

Gets a Set containing all UDFs, represented as Function documents, for the database. To limit the returned Set, you can provide an optional range.

Function documents are FQL versions of a database’s FSL function schema. Function documents have the FunctionDef type. See User-defined functions (UDFs).

If Function.all() is the last value in a query, the first page of the Set is returned. See Pagination.

Staged schema

If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.

Parameters

Parameter Type Required Description

range

{ from: Any } | { to: Any } | { from: Any, to: Any }

Specifies a range of Function documents in the form { from: start, to: end }.

The Set only includes documents in this range (inclusive). Omit from or to to run unbounded range searches.

If a range is omitted, all UDFs are returned.

Range parameters

Name Type Required Description

from

Any

Beginning of the range (inclusive). Must be an Function document.

to

Any

End of the range (inclusive). Must be an Function document.

Return value

Type Description

Set<FunctionDef>

Set of Function documents in the provided range. If a range is omitted, all UDFs are returned.

The Set is empty if:

  • The database has no UDFs.

  • There are no UDFs in the provided range.

  • The provided range’s from value is greater than to.

Examples

Function.all()
{
  data: [
    {
      name: "validateOrderStatusTransition",
      coll: Function,
      ts: Time("2024-10-25T17:49:28.145Z"),
      body: <<-END
        (oldStatus, newStatus) => {
          if (oldStatus == "cart" && newStatus != "processing") {
            abort("Invalid status transition.")
          } else if (oldStatus == "processing" && newStatus != "shipped") {
            abort("Invalid status transition.")
          } else if (oldStatus == "shipped" && newStatus != "delivered") {
            abort("Invalid status transition.")
          }
        }
      END
    },
    ...
  ]
}

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!