Sequelize.js 正在获取实例。\u Sequelize 6中的modelOptions
在Sequelize 5中,我的实例如下所示:Sequelize.js 正在获取实例。\u Sequelize 6中的modelOptions,sequelize.js,Sequelize.js,在Sequelize 5中,我的实例如下所示: recentItem { dataValues: { id: 't4qupOzsuPrxLuHkLiYwA', createdAt: 2019-07-23T22:07:43.727Z, updatedAt: 2020-07-08T19:30:13.348Z, entityId: 'SJleJVAA_z' }, _previousDataValues: { id: 't4qupOzsuPrxLuHk
recentItem {
dataValues: {
id: 't4qupOzsuPrxLuHkLiYwA',
createdAt: 2019-07-23T22:07:43.727Z,
updatedAt: 2020-07-08T19:30:13.348Z,
entityId: 'SJleJVAA_z'
},
_previousDataValues: {
id: 't4qupOzsuPrxLuHkLiYwA',
createdAt: 2019-07-23T22:07:43.727Z,
updatedAt: 2020-07-08T19:30:00.122Z,
entityId: 'SJleJVAA_z'
},
_changed: { updatedAt: true },
_modelOptions: {
timestamps: true,
validate: {},
freezeTableName: false,
underscored: false,
paranoid: false,
rejectOnEmpty: false,
whereCollection: {
entityId: 'SJleJVAA_z'
},
schema: null,
schemaDelimiter: '',
defaultScope: {},
scopes: {},
indexes: [],
name: { plural: 'recentItems', singular: 'recentItem' },
omitNull: false,
sequelize: Sequelize {
options: [Object],
config: [Object],
dialect: [PostgresDialect],
queryInterface: [QueryInterface],
models: [Object],
modelManager: [ModelManager],
connectionManager: [ConnectionManager],
importCache: [Object],
Op: [Object],
Promise: [Function]
},
hooks: {}
},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [ 'id', 'createdAt', 'updatedAt', 'entityId' ]
},
isNewRecord: false
}
在Sequelize 6中,我没有_model选项。如何获取模型信息(“模型选项”)?之所以需要它,是因为该实例可能是几种不同型号中的一种。我在这里找到了解决方案:
使用
recentItem.constructor.options