Skip to main content
A mutation writes with six verbs. Each one states what it assumes about the fact, and what it leaves. A query has no write verb: a write in a query is a type error.

Strict writes

insert, replace, patch and delete are strict: each assumes the fact’s state, and the assumption is a read. A false assumption refuses the whole transaction with Exists or Absent, and nothing it wrote commits.
bijection/notes.ts
On a table that mints keys, ctx.insert(table, fact) returns the new key. On a table with a declared key, insert at the point: ctx.insert(prices(sku), { amount }). An insert also refuses Exists when a unique field set is taken.

Blind writes

put and retract read nothing and never refuse. Readers see them exactly: a blind write conflicts with a read only when it changes what that read returned or counted. ctx.put(point, fact) makes the fact be this, whatever was there; ctx.retract(point) makes the point hold nothing, and does nothing when it already holds nothing.
On a table that mints its keys, ctx.retract also takes a unique field set, ctx.retract(users({ email })). The host removes the fact holding it without reading it into the transaction: neither its fields nor whether one was there reach your code, and erasing that fact later never closes what the transaction wrote. ctx.put still takes only the key: to change the fact a unique field set names, ctx.patch or ctx.replace it. A blind write may go above its function’s under, unless the table declares a constraint. unique, a capacity, a pin quota and a t.shared field are reads, so a write into such a table stays at or below under (Constraints are reads). A lifetime is not a constraint: a blind write into a lifetime table expires lifetime after its own commit. Use a blind write when the new state does not depend on the old one, such as a value copied from a source of truth. Use a strict write when the change only makes sense against the fact you expect.

Writes at valid time

On a series or timeline, a write names its valid time in the address.
See Series and timelines.

Refusing a write yourself

A mutation refuses with ctx.refuse(code, message), with one of its declared refuses codes. The refusal leaves the mutation: nothing it wrote commits, even if its own code catches it. A caller that entered it with ctx.try gets the refusal as a Result and can still commit (calls).
See Errors for Result and the host codes.

What a write may touch

  • A write into a labelled table needs a function whose under flows to the table’s label. See Write rules.
  • The sys tables are read-only to the six writes: grants, tasks, branches, pins, disclosures and erasures change only through their grave acts. See System tables.
  • A guard may refuse a write it covers. A refused write refuses the transaction with Forbidden.

Transactions

Every write in a mutation commits together, or none does. See Transactions and conflicts.

Operational data fixes

Declare a mutation with allow: [operator] and include it in bijection.lock. The table’s writers applies to the mutation. Operators call it with bijection mutate. See CLI verbs.