type
CollectionHooks
Register callbacks for collection or global reads, writes, and other lifecycle events.
Properties
| Property | Type | Description |
|---|---|---|
BeforeDuplicate | []Hook | BeforeDuplicate runs after the source is access-checked and copied but before validation. |
BeforeValidate | []Hook | BeforeValidate runs before field hooks and built-in checks for create, duplicate, update, publish, and unpublish. On updates, Data contains only the submitted fields. |
BeforeChange | []Hook | BeforeChange runs after initial built-in validation for create, duplicate, update, publish, and unpublish. Changes to Data are checked again afterward; custom field validators run after the write hooks finish. |
BeforeOperation | []Hook | BeforeOperation runs before the store operation, including reads and deletes. On writes it follows BeforeChange; changed values are validated before saving. |
BeforeRead | []Hook | BeforeRead runs before one or many documents are read. |
BeforeDelete | []Hook | BeforeDelete runs after the original document is loaded but before deletion. |
AfterChange | []Hook | AfterChange runs after create, duplicate, update, publish, or unpublish has saved the document, but before commit. Returning an error rolls back the save. |
AfterRead | []Hook | AfterRead runs for each response document, including mutation responses, after computed fields resolve and before field read access removes values. |
AfterDelete | []Hook | AfterDelete runs inside the transaction after deletion or trashing. |
AfterOperation | []Hook | AfterOperation runs after the store operation, including reads and deletes, but before response processing and commit. Errors can still roll back writes. |
AfterError | []Hook | AfterError observes a failure in this resource through Error. It cannot suppress that failure; its own error is added to the returned error. |
AfterCommit | []Hook | AfterCommit runs after a change commits: creates, duplicates, updates, publishing, deletes, and restores, but never reads. It runs outside the transaction; failures cannot roll back saved data, and later effects still run. |