Replies: 2 comments
-
Hey @thgh — the types set I do believe we can inject the const beforeChangeHook = (slug: string): CollectionBeforeChangeHook => ({ req: { payload }}) => {
const collection = payload.collections[slug].config
// do stuff here
}
const myCollectionSlug = 'my-collection'
const collection: CollectionConfig = {
slug: myCollectionSlug,
hooks: {
beforeChange: [
beforeChangeHook(myCollectionSlug),
]
},
// more collection stuff here
} I'm going to convert this to a discussion and then mark it as planned so we can treat this as a feature request and get this built though. 👍 thanks for the idea! |
Beta Was this translation helpful? Give feedback.
-
I'm editing things from the admin UI which seems to be using the REST API. Cool to see it planned! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
The typing of
CollectionBeforeChangeHook
suggestscollection
may be available, but it is not.It is available in
CollectionBeforeOperationHook
->args.collection
so could be a quick win to pass it inbeforeChange
hooksCurrent Behavior
Expected Behavior
Possible Solution
Would be even handier if the collection object were passed at the toplevel instead of
req
Steps to Reproduce
Beta Was this translation helpful? Give feedback.
All reactions