type

HookContext

The request, document, actor, locale, and transaction state available to a hook.

Source ridu.go:86

Contextcontext.Context
Cancellation, deadline, and transaction context.
OperationOperation
The active lifecycle operation.
CollectionIDschema.StableID
Target collection identity.
GlobalIDschema.StableID
Target global identity, when applicable.
Actor*store.Document
Authenticated actor, or nil.
ActorCollectionschema.CollectionSlug
ActorCollection identifies the exact auth collection that owns Actor.
Datastore.Values
Mutable incoming values.
Document*store.Document
Current operation result.
Original*store.Document
Document before update or delete.
Local*LocalAPI
Nested operations; pre-commit phases reuse the transaction.
FieldPathstring
Path for a field-scoped hook.
Errorerror
Original failure for AfterError.
Localeschema.LocaleCode
Selected locale.
AllLocalesbool
Whether every locale is selected.

Most applications import the ridu.HookContext alias from the root package. AfterCommit and AfterError run outside the original transaction.

This is the application-facing alias of core.HookContext. Import it from github.com/riducms/ridu in ordinary application code.

Example

go
func normalizeTitle(ctx ridu.HookContext) error {
  title, ok := ctx.Data["title"].StringValue()
  if !ok {
    return nil
  }
  ctx.Data["title"] = store.String(strings.TrimSpace(title))
  return nil
}