Hooks (Function that run after creating a document)

If a document gets created, I want to run a function as a hook.

The hook should include the document as a prop:
(doc) => { }

Use Case:
We have a questionnaire where the user answers questions. The answers, together with the question, will be stored in the collection Decision. Based on the selected answer, we activate specific new questions. Currently we trigger the activation of new questions in the frontend. But we would like to move the functionality fully into fauna to reduce network ping pong and to reduce system complexity. Having a hook, we could trigger the activate new question function reactive when the document Decision got updated with the answer.

Related to this existing topic:

Though, admittedly, the existing one may be overly broad covering both internal hooks/triggers as well as webhooks.

1 Like