Function()

Dynamically get the Function by name.

Signature

Function(name: String): Any

Description

The Function() method gets the name function.

Parameters

Parameter Type Required Description

name

String

Yes

Function name

Return value

Type Description

Any

The name function.

Examples

Get the function by directly naming the function:

Product.where(.name == 'pizza')
{
  data: [
    {
      id: "386968888565301316",
      coll: Product,
      ts: Time("2024-01-15T06:45:40.390Z"),
      name: "pizza",
      description: "Frozen Cheese",
      price: 4.99,
      quantity: 92,
      store: Store.byId("386968888560058436"),
      backorderLimit: 15,
      backordered: false
    }
  ]
}

 

This equivalent expression gets the function by passing the name of the function as a parameter:

Collection('Product').where(.name == 'pizza')
{
  data: [
    {
      id: "386968888565301316",
      coll: Product,
      ts: Time("2024-01-15T06:45:40.390Z"),
      name: "pizza",
      description: "Frozen Cheese",
      price: 4.99,
      quantity: 92,
      store: Store.byId("386968888560058436"),
      backorderLimit: 15,
      backordered: false
    }
  ]
}

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!