type

Hook

type Hook func(HookContext) error

A collection lifecycle callback.

Source core/hook.go:42

@param ctx
The current operation and transaction state.
@returns
Before commit, an error fails and rolls back the operation. AfterCommit errors report a committed failure.

Example

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

Related types

  • HookContext

    Transactional operation state passed to lifecycle hooks.