type

Hook

Run code during a collection or global lifecycle phase.

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
}

Properties

PropertyTypeDescription
ctxHookContextThe 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.

error

How 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.

Full signature

Related guides