Remote / Declared writes

Computed field assignments

Use compute to derive a field from the pre-write row and input inside the same SQL statement using declared operators:

ts
const suffixed = Expr.operator('acme.suffixed', {
  input: [Schema.String, Schema.String],
  output: Schema.String,
})

const Rebrand = Mutation.write(
  'Rebrand',
  Write.update(
    Entity.input(
      Product,
      Schema.Struct({ id: Schema.String, revision: Schema.Number, suffix: Schema.String }),
      { suffix: Entity.unmapped },
    ),
    {
      id: 'id',
      expect: 'revision',
      compute: { name: ({ row, input }) => suffixed(row.name, input.suffix) },
    },
  ),
)

Register operator implementations in both your server binding and Remote.make({ operators }) (see An operator the application implements). Unpinned compute writes without expect require a ledger plus either a revision-pinned guard or a verified commutative operator.