I need to get some data using a previously defined Sequelize Model.
What I need:
* attributes list * attribute name * attribute type (INTEGER, STRING,...) * was it generated by association method? * list of associations * association type (belongsTo, hasMany, ...)
For some reason, itโs quite difficult to test the Sequelize models in the console:
> db.sequelize.models.Payment Payment // <- it valid Sequelize Model {Object}, however its not inspectable > db.sequelize.models.Payment.attributes ... type: { type: { values: [Object] }, values: [ 'cash', 'account', 'transfer' ], Model: Payment, fieldName: 'type', _modelAttribute: true, field: 'type' }, sum: { type: { options: [Object], _length: undefined, _zerofill: undefined, _decimals: undefined, _precision: undefined, _scale: undefined, _unsigned: undefined }, Model: Payment, fieldName: 'sum', _modelAttribute: true, field: 'sum' }, ...
As you can see, there is no actual information about the types of fields. The same thing happens with associations.
So, is there any reliable โofficialโ way to extract this data from the Model class without digging and reversing the object?