From the course: Building APIs with LoopBack

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Operation hooks in action

Operation hooks in action - Node.js Tutorial

From the course: Building APIs with LoopBack

Start my 1-month free trial

Operation hooks in action

- [Instructor] In the last lesson, we talked about remote hooks. Operation hooks are similar but are not modifying API calls. On the other hand though, they can be fired based on API calls. So what do I mean? Operation hooks are low-level methods related to how LoopBack loads and works with data. So when I do a remote call to load a Cat, there is the API, and LoopBack recognizing that remote call, and then there is the low-level call to find and return Cat data. If LoopBack is using the in-memory data source, it will just find that record and RAM, or from the file. If it is using Mongo, than it will speak to the Mongo server and get the record. These operation hooks then let you work with that process and do modifications. For options, you've got a set of them that are all related to CRUD. So access, for example, would be any read. Before and after save and delete are write related options. Loaded is also a read and persists as related to write. If you remember, I said that LoopBack…

Contents