Example User Action Code Logging
- Released
- Jul 09, 2023
- Requested By
- leandro-hermes
- Series
- AdonisJS Quick Tip
- Status
-
Done
- View
- View Content
Notes
Only the first five paragraphs of our notes will be publicly displayed below.
In this lesson, we’ll be taking a look at how we can log any and every user action performed against our AdonisJS models.
AdonisJS Hooks
AdonisJS 5 uses hooks as its event system to notify us when a particular action is run against our models. Each of the hooks has both a before and after variant.
So, if you wanted to know when an action was attempted, you would want to utilize the before variant. If you wanted to know when an action was successfully performed, you’d want to use the after variant.
All of the available hooks can be found in the AdonisJS documentation, under ORM inside the Hooks page.