function.update()

Learn: User-defined functions (UDFs)

We recommend you use FSL to create and update user-defined functions (UDFs). See FSL function schema.

Update function fields.

Signature

update(object: {*: Any}) => FunctionDef

Description

The update() method updates the Function definition with the given object values. The object must have valid field names.

Staged schema

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

For more information, see Run a staged schema change.

Parameters

Parameter Type Required Description

object

Object

Yes

Function field and values to update.

Return value

Type Description

FunctionDef

Function definition with updated fields.

Examples

Function.byName("inventory")?.update({
  name: "inventory",
  body: <<-END
    (name) => {
      Product.byName(name) {
        name: .name,
        description: .description,
        stock: .stock,
        price: .price
      }
    }
  END,
  role: "server"
})
{
  name: "inventory",
  coll: Function,
  ts: Time("2099-04-10T18:22:31.475Z"),
  role: "server",
  body: <<-END
    (name) => {
      Product.byName(name) {
        name: .name,
        description: .description,
        stock: .stock,
        price: .price
      }
    }
  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!