Add the populate hook
When we obtain a teams record, we want to add the team's users to the team record. This requires a hook and therefore we generate the scaffolding for a hook using:
feathers generate hook
The directory has changed:
The populateTeams hook
The generator has roughed out an after hook for the
This hook doesn't do anything so far, but its been placed in the structure and wired into the app.
This caused the following modules to be added:
src/hooks/populate-teams.js contains code for a hook that presently does nothing.
test/hooks/populate-teams.test.js tests that the hook is configured.
The hook had to be wired into the app, so the generator made the following changes:
- src/services/teams/teams.hooks.js now
populateTeams. We told the generator to create an
afterhook for the
findmethod, and that is when it is being run.
The generated code, once again, contains no surprises for us as we have covered it before. Now we can run our application.