type

UpdateRequest

An authorized update with values and one explicit publication-head intent.

Properties

PropertyTypeDescription
RequestRequestThe Request value.
ValuesValuesThe Values value.
IntentWriteIntentDraft-capable writes require SaveDraft, Publish, Unpublish, or DiscardDraft. An ordinary update cannot implicitly replace the live head.
ReplaceValuesboolReplaceValues treats Values as the complete canonical authored document state, including locale maps. Omitted fields and locales are removed. The default remains a patch so ordinary updates preserve omitted values. Framework version restore uses replacement after access, validation, hooks, and reference checks have produced the canonical snapshot candidate.
Current*DocumentCurrent is required. It is the whole working document as it stands in this transaction, including its published metadata: read with Find and Request.CurrentRequest, and read again in the same way whenever this transaction wrote the row after that read. The row lock keeps other transactions from changing it, so adapters update from it and never read the row again. Only framework code supplies it: the operation engine, which re-reads a locked document that an earlier write in the transaction (such as a hook's nested Local API call) changed, and the migration data transaction, which performs the read itself. Adapters write only while the stored row is still the version Current describes. Every write advances updated_at, and revision on a versioned or upload resource, so a Current that misses a later write in the same transaction, or was not read from the store at all, fails with ErrConflict and never becomes the basis of a write.

Full signature

type UpdateRequest struct { Request Values Values // Intent makes publication-head transitions explicit. Draft-enabled // collections require SaveDraft, Publish, Unpublish, or DiscardDraft. // Default updates on versions-only collections keep the live head current. // SaveDraft and DiscardDraft require draft-enabled collections. Intent WriteIntent // ReplaceValues treats Values as the complete canonical authored document // state, including locale maps. Omitted fields and locales are removed. The // default remains a patch so ordinary updates preserve omitted values. // Framework version restore uses replacement after access, validation, hooks, // and reference checks have produced the canonical snapshot candidate. ReplaceValues bool // Current is required. It is the whole working document as it stands in // this transaction, including its published metadata: read with Find and // Request.CurrentRequest, and read again in the same way whenever this // transaction wrote the row after that read. The row lock keeps other // transactions from changing it, so adapters update from it and never // read the row again. Only framework code supplies it: the operation // engine, which re-reads a locked document that an earlier write in the // transaction (such as a hook's nested Local API call) changed, and the // migration data transaction, which performs the read itself. // // Adapters write only while the stored row is still the version Current // describes. Every write advances updated_at, and revision on a versioned // or upload resource, so a Current that misses a later write in the same // transaction, or was not read from the store at all, fails with // ErrConflict and never becomes the basis of a write. Current *Document }

Source store/store.go:140

Methods

  • UpdateRequest.LockedCurrent()

    LockedCurrent returns the required Current document after checking that it identifies the requested document. The returned Values are shared: callers that edit them must clone first.