@dxos/echo
    Preparing search index...

    Function update

    • Perform mutations on an entity (object or relation) within a change context.

      Entities are read-only by default. Mutations are batched and notifications fire when the callback completes. Direct mutations outside of Entity.update will throw at runtime.

      Type Parameters

      Parameters

      • entity: T

        The echo entity (object or relation) to mutate.

      • callback: ChangeCallback<T>

        Receives a mutable view of the entity. All mutations must occur here.

      Returns void

      // Mutate within Entity.update
      Entity.update(entity, (obj) => {
      obj.name = 'Updated';
      obj.count = 42;
      });

      // Direct mutation throws
      entity.name = 'Bob'; // Error: Cannot modify outside Entity.update()

      Note: For type-specific operations, prefer Obj.update or Relation.update.

      Synchronous; costs the mutations made in the callback plus one batched notification.