beforeChangeHook
beforeChangeHook<
TCollectionSlug,TDataModel>(slug,fn): (<TDataModel>(props) =>TDocument|Promise<TDocument>) |undefined
Defined in: packages/core/src/collections/hooks.ts:125
Types a collection’s beforeChange hook against a real collection,
DataModel, and resolved CollectionConfig, without touching
BeforeChangeProps directly. TCollectionSlug is inferred from slug;
supply TDataModel explicitly for a typed ctx.
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string
TDataModel
Section titled “TDataModel”TDataModel extends GenericDataModel = GenericDataModel
Parameters
Section titled “Parameters”TCollectionSlug
The collection slug doc/collection should be typed as —
pass the same constant the collection itself is defineCollection({ slug })-ed
with (e.g. TABLE_SLUG_PAGES), not a fresh string literal, so a rename
of one renames the other.
(props) => TDocument | Promise<TDocument>
The hook function, checked against the real types.
Returns
Section titled “Returns”(<TDataModel>(props) => TDocument | Promise<TDocument>) | undefined
The same function, re-typed to the collection’s loose public hooks.beforeChange signature.