Model 有没有办法通过先前定义的Sequelize模型获取属性//关联?

Model 有没有办法通过先前定义的Sequelize模型获取属性//关联?,model,sequelize.js,Model,Sequelize.js,我需要通过先前定义的Sequelize模型获得一些数据 我需要的是: * attributes list * attribute name * attribute type (INTEGER, STRING,...) * was it generated by association method? * list of associations * association type (belongsTo, hasMany, ...) 由于某些原因,在控制台中检查Sequeliz

我需要通过先前定义的Sequelize模型获得一些数据

我需要的是:

* attributes list
  * attribute name
  * attribute type (INTEGER, STRING,...)
  * was it generated by association method?
* list of associations
  * association type (belongsTo, hasMany, ...)
由于某些原因,在控制台中检查Sequelize型号相当困难:

> db.sequelize.models.Payment
Payment // <- it's 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' },
 ...
>db.sequelize.models.Payment

Payment/尝试
Payment.rawtattributes
,它是一个以属性名称为键的对象,也是一个具有属性详细信息的对象
property.type.key
是类型为的字符串


Payment.associations
是关联的对象-键是名称,每个关联都有一个
associationType
属性-您还可以执行sequelize.association.BelongsTo
等的
关联实例。

谢谢。在彻底搜索堆栈溢出后,我开始遍历Sequelize代码,并获得了对模型属性的访问。当数据类型显示为
ABSTRACT{length:255}
时,无法理解如何读取该数据类型。以上两项都可以。要将类型作为数据库中使用的字符串,可以执行
ModelName.rawtattributes.propertyName.type.toSql()
谢谢!今天刚用过。这个神秘的“类型”对象及其包含的所有属性/方法是否有文档?我没有看到任何文档,但类型是
AbstractDataType
,其代码如下: