Tokens Sequelize plugin
This plugin allows to quickly attach tokens to any Sequelize model
Install
npm install sequelize-tokens
and then attach the plugin:
Sequelize;
Usage
Declare token in model definition options:
sequelize;
Such a definition gives to Model and each its instances the following superpowers:
-
associations
typeAToken
,typeBToken
This allows to fetch the token (of any type) along with fething the entity itself:
Model; -
instance methods
instance.createTypeAToken()
,instance.getTypeAToken()
andinstance.setTypeAToken({...})