5
Adding Hooks and Lifecycle Events to Your Models
ORM typically provides a way for us to be able to transform states, or objects, throughout events that occur when executing certain operations. These methods are often referred to as hooks, lifecycle events, object lifecycles, or even callbacks (the latter is not often used within the Node.js community due to a nomenclature conflict against Node.js’ native environment). Usually, these methods have a temporal prefix (for example, before and after) preceding an event’s name.
There are no strict rules as to what an ORM requires as an event throughout its entire lifecycle. The events typically included within an ORM are called: validation, save, create, update, and destroy. Other ORM frameworks ...
Get Supercharging Node.js Applications with Sequelize now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.