type

CollectionHooks

Ordered lifecycle callbacks for one collection.

Source ridu.go:67

BeforeDuplicate[]Hook
Prepare a copied document before validation.
BeforeValidate[]Hook
Normalize values before validation.
BeforeChange[]Hook
Derive values before persistence.
BeforeOperation[]Hook
Run immediately before storage.
BeforeRead[]Hook
Prepare document reads.
BeforeDelete[]Hook
Run before a loaded document is deleted.
AfterChange[]Hook
React to persistence inside the transaction.
AfterRead[]Hook
Decorate a result before field redaction.
AfterDelete[]Hook
React to deletion inside the transaction.
AfterOperation[]Hook
Run before the operation commits.
AfterError[]Hook
Observe resource failures.
AfterCommit[]Hook
Run after a successful commit.

Each hook slice runs in order. In FieldHooks, BeforeRead and AfterError remain resource-level phases, and map order across paths is not significant.

Each hook slice runs in order. In FieldHooks, BeforeRead and AfterError are not field-level phases, and map order across field paths is not significant.

Example

go
var Posts = ridu.Collection{
  Hooks: ridu.CollectionHooks{
    BeforeValidate: []ridu.Hook{normalizeSlug},
    AfterChange:    []ridu.Hook{recordAuditEntry},
    AfterCommit:    []ridu.Hook{enqueueSearchIndex},
  },
}