type
Hook
Run code during a collection or global lifecycle phase.
Example
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
}Properties
| Property | Type | Description |
|---|---|---|
ctx | HookContext | The operation, user, values, and local API for this phase. Change Data entries before saving or Document.Values to change the response. |
Returns
Before commit, an error fails and rolls back the operation. AfterCommit errors report a committed failure.
errorHow it works
Return nil to continue or an error to stop. A pre-commit error rolls back the operation; an AfterCommit error cannot undo saved data.