Hook after every change #1438
Replies: 2 comments
-
A collection hook would handle all field hooks, so there would be no need to run this action on field hooks. So to do it, you could write a function that does this, and import into all collections/globals, and add it to the afterChange hooks. There is no global hook that catches all changes. Curious why would you want to do this? |
Beta Was this translation helpful? Give feedback.
-
Instead of adding your hook to every collection, you could use the postMiddleware that would run on every request. Then you can conditionally call your function on POST and PATCH requests. That's maybe the closest thing to a global hook. You won't get as nice of data to work with as you do with hooks though. For example no originalDoc and the Request data may be different from Payload's doc data after handling the request. I would probably use hooks, but it depends what you're trying to do. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I am having troubles finding the right solution for this, so would appreciate any feedback.
I see there are per-field, per-collection or per-globals hooks. However, I would like to have a hook that reacts to every data change and instantiate it somewhere once (like an admin pannel).
[Goal is to, on every change, backup mongoDB]
How could I achieve it?
Beta Was this translation helpful? Give feedback.
All reactions