replace()

Replace function fields.

Signature

replace(object: {*: Any}): FunctionDef

Description

The replace() method replaces the given object function field values with the given object values. The given fields must exist and be mutable.

Parameters

Parameter Type Required Description

object

Object

Yes

Replacement function fields.

Return value

Type Description

FunctionDef

Function with replaced fields.

Examples

Function.byName("inventory")?.replace({
  name: "inventory",
  body: <<-END
    (name) => {
      Product.byName(name) {
        name: .name,
        description: .description,
        quantity: .quantity,
        price: .price
      }
    }
  END,
  role: "server"
})
{
  name: "inventory",
  coll: Function,
  ts: Time("2099-04-10T18:21:19.743Z"),
  body: <<-END
    (name) => {
      Product.byName(name) {
        name: .name,
        description: .description,
        quantity: .quantity,
        price: .price
      }
    }
  END,
  role: "server"
}

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!