Sequelize: Class & Instance Methods

Mike Frey
InstructorMike Frey

Share this video with your friends

Send Tweet

Models in the Node.js ORM, Sequelize, can be expanded with both class level and instance level functions. This video will show you how to extend your models to add helpers or business logic, and explain the methods execution scope.

Prith
Prith
~ 5 years ago

implementation wise, what's the difference between class methods and instance methods? As in, in what scenarios will we be using each of them?

Mike Frey
Mike Freyinstructor
~ 5 years ago

Generally, if you want to act on a single instance, you'd create an instance method. If you want to act on multiple instances, such as, a method for helping query the database, you'd create a class method.