Function.byName()

Get a user-defined Function document by its name.

Signature

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

Description

The Function.byName() method gets the Function object if it exists and is accessible.

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("inventory")
    {
      name: "inventory",
      coll: Function,
      ts: Time("2099-04-10T17:50:39.955Z"),
      body: <<-END
        (name) => {
          Product.byName(name) {
            name: .name,
            description: .description,
            quantity: .quantity
          }
          
        }
      END,
      role: "server"
    }
  2. When the UDF document doesn’t exist or is inaccessible:

    Function.byName("doesnotexist")
    Function.byName("doesnotexist") /* not found */

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!