type

Context

Context describes one field callback at its current lifecycle phase. Root, Siblings and Prior are detached, immutable snapshots of field values; document metadata such as ID is available separately on Context. A callback changes its own value only through its return value.

Properties

PropertyTypeDescription
Contextcontext.ContextContext carries the operation's cancellation and deadline. Pass it to Local.
OperationKindOperation is the enclosing document operation, such as Create or Update, rather than the hook phase currently running.
CollectionIDschema.StableIDCollectionID identifies the collection; it is empty for a global. This is a framework resource identifier, not its authored slug.
GlobalIDschema.StableIDGlobalID identifies the global; it is empty for a collection. This is a framework resource identifier, not its authored slug.
OccurrenceIDOccurrenceIDOccurrenceID correlates this field value, including its enclosing stable row keys and exact locale where localized. It is not a document ID.
SchemaOccurrenceIDOccurrenceIDSchemaOccurrenceID groups callbacks for the same configured field across repeated rows and locales. Most application callbacks need neither token.
IDIDID identifies the document involved in this phase. It can be empty before a newly created document has been assigned an ID.
ActorActorActor identifies the authenticated document and owning auth collection. Actor.ID is empty for an anonymous operation.
Localeschema.LocaleCodeLocale is the selected content locale, or the exact translation when an all-locales operation visits a localized value. It is empty without localization. On ordinary reads it does not identify a fallback value's source locale.
AllLocalesboolAllLocales reports whether Root retains locale-keyed values. A callback visiting one exact translation receives false even during an all-locales read.
RootViewRoot contains root field values at this phase: input during raw hooks, the completed candidate during typed writes and validation, or response values during reads. Read values may include requested population and fallback.
SiblingsViewSiblings contains the current enclosing object or repeated row, including this field. For a root title it is the root; for seo.title it is seo; for variants[_key=A].sku it is row A, regardless of that row's current index.
PriorViewPrior contains the previous persisted enclosing object or row, including this field. Prior.String("title") reads the previous title, not the whole previous document. Retained rows match by stable key rather than array index. It is empty when no previous enclosing object exists, including create, new rows and standalone reads. Localized writes use the exact prior locale; fallback text never becomes a previously stored translation.
LocalReaderLocal reads a known document under this callback's actor and exact locale, reusing an active transaction. It does not grant nested write capabilities.

Full signature

type Context struct { // Context carries the operation's cancellation and deadline. Pass it to Local. Context context.Context // Operation is the enclosing document operation, such as Create or Update, // rather than the hook phase currently running. Operation Kind // CollectionID identifies the collection; it is empty for a global. // This is a framework resource identifier, not its authored slug. CollectionID schema.StableID // GlobalID identifies the global; it is empty for a collection. // This is a framework resource identifier, not its authored slug. GlobalID schema.StableID // OccurrenceID correlates this field value, including its enclosing stable // row keys and exact locale where localized. It is not a document ID. OccurrenceID OccurrenceID // SchemaOccurrenceID groups callbacks for the same configured field across // repeated rows and locales. Most application callbacks need neither token. SchemaOccurrenceID OccurrenceID // ID identifies the document involved in this phase. It can be empty before // a newly created document has been assigned an ID. ID ID // Actor identifies the authenticated document and owning auth collection. // Actor.ID is empty for an anonymous operation. Actor Actor // Locale is the selected content locale, or the exact translation when an // all-locales operation visits a localized value. It is empty without localization. // On ordinary reads it does not identify a fallback value's source locale. Locale schema.LocaleCode // AllLocales reports whether Root retains locale-keyed values. A callback // visiting one exact translation receives false even during an all-locales read. AllLocales bool // Root contains root field values at this phase: input during raw hooks, // the completed candidate during typed writes and validation, or response // values during reads. Read values may include requested population and fallback. Root View // Siblings contains the current enclosing object or repeated row, including // this field. For a root title it is the root; for seo.title it is seo; // for variants[_key=A].sku it is row A, regardless of that row's current index. Siblings View // Prior contains the previous persisted enclosing object or row, including // this field. Prior.String("title") reads the previous title, not the whole // previous document. Retained rows match by stable key rather than array index. // It is empty when no previous enclosing object exists, including create, // new rows and standalone reads. Localized writes use the exact prior locale; // fallback text never becomes a previously stored translation. Prior View // Local reads a known document under this callback's actor and exact locale, // reusing an active transaction. It does not grant nested write capabilities. Local Reader }

Source operation/contract.go:54

Related guides