type

CollectionHooks

Register callbacks for collection or global reads, writes, and other lifecycle events.

Properties

PropertyTypeDescription
BeforeDuplicate[]HookBeforeDuplicate runs after the source is access-checked and copied but before validation.
BeforeValidate[]HookBeforeValidate runs before field hooks and built-in checks for create, duplicate, update, publish, and unpublish. On updates, Data contains only the submitted fields.
BeforeChange[]HookBeforeChange 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[]HookBeforeOperation runs before the store operation, including reads and deletes. On writes it follows BeforeChange; changed values are validated before saving.
BeforeRead[]HookBeforeRead runs before one or many documents are read.
BeforeDelete[]HookBeforeDelete runs after the original document is loaded but before deletion.
AfterChange[]HookAfterChange runs after create, duplicate, update, publish, or unpublish has saved the document, but before commit. Returning an error rolls back the save.
AfterRead[]HookAfterRead runs for each response document, including mutation responses, after computed fields resolve and before field read access removes values.
AfterDelete[]HookAfterDelete runs inside the transaction after deletion or trashing.
AfterOperation[]HookAfterOperation runs after the store operation, including reads and deletes, but before response processing and commit. Errors can still roll back writes.
AfterError[]HookAfterError observes a failure in this resource through Error. It cannot suppress that failure; its own error is added to the returned error.
AfterCommit[]HookAfterCommit 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.

Full signature

Related guides