update()

Add the provided fields to the existing fields.

Signature

update(object: { *: Any }): CollectionDef

Description

The update() method updates the Collection definition with the given object values.

The object must have valid field names.

The method does not check for duplicate field names.

A query can’t update a collection’s definition and write to documents in the collection. Use separate queries instead.

Parameters

Parameter Type Required Description

object

Object

Yes

Collection field and values to update.

Return value

Type Description

CollectionDef

Collection definition with updated fields.

Examples

  1. View the current document:

    Customer.byId('387120252471738436')
    {
      id: "387120252471738436",
      coll: Customer,
      ts: Time("2024-01-16T22:51:32.170Z"),
      identifier: "00123"
    }
  2. Update the current document:

    Customer.byId('387120252471738436')!.update({name: "Alex"})
    {
      id: "387120252471738436",
      coll: Customer,
      ts: Time("2024-01-16T23:27:32.533Z"),
      identifier: "00123",
      name: "Alex"
    }

See also

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!