Function.byName()

Get a user-defined Function document by its name.

Signature

Function.byName(name: string): FunctionDef | NullFunctionDef

Description

Each user-defined Function (UDF) document in a Fauna database is represented by a Function object, and each UDF has a name. Function.byName() gets a UDF document by its name.

Returns the Function object if it exists and is accessible. Otherwise, returns null.

Parameters

Parameter Type Required Description

name

String

Yes

Name of the UDF document to get.

Return value

One of:

Type Description

FunctionDef

Function object. See Function document definition.

NullFunctionDef

UDF document doesn’t exist or is inaccessible.

Examples

  1. Fetch a UDF when it exists and is accessible:

    Function.byName("Double")
    {
      name: "Double",
      coll: Function,
      ts: Time("2022-10-25T21:01:19.310Z"),
      body: "(x) => x + x"
    }
  2. When the UDF document doesn’t exist or is inaccessible:

    Function.byName("doesnotexist")
    null

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!