type
Observer
Run code at a field event without returning a replacement value.
Arguments
| Argument | Type | Description |
|---|---|---|
ctx | operation.EventContext | The operation, user, surrounding field values, and access-checked reader for this phase. |
value | operation.Value[T] | This field’s value at the event. The context and value let you inspect what happened without mutating surrounding fields. |
Returns
Return nil to continue or an error to stop. Errors before commit roll back the operation; AfterCommit errors report failure after the data is saved.
errorHow it works
Use for BeforeDelete, AfterChange, AfterDelete, AfterOperation, and AfterCommit. Check ctx.Operation when the work should run only for writes.
Full signature
type Observer[T any] func(
operation.EventContext,
operation.Value[T],
) errorRelated types
EventContextEventContext is the view for field lifecycle observations. Observation callbacks do not return mutations to field or ambient document values.
ValueValue carries an optional logical value. Its zero value is empty. For raw input, empty means omitted and Present(store.Null()) means explicit null. For typed scalars, empty is the portable empty state, not a durable absence encoding. T must follow its own ownership contract; this carrier does not deep-clone arbitrary mutable application values.