type

Hook

A deterministic lifecycle callback.

Source ridu.go:85

ctxHookContext
The current operation and transaction state.

Returns error Before commit, an error fails and rolls back the operation. AfterCommit errors report a committed failure.

Example

go
var auditTitle ridu.Hook = func(ctx ridu.HookContext) error {
  if ctx.Document == nil {
    return nil
  }
  log.Printf("%s changed %s", ctx.Operation, ctx.Document.ID)
  return nil
}