Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_ModelOptions removed from instance in V6 #12486

Closed
2 of 7 tasks
WaylonOKC opened this issue Jul 10, 2020 · 3 comments
Closed
2 of 7 tasks

_ModelOptions removed from instance in V6 #12486

WaylonOKC opened this issue Jul 10, 2020 · 3 comments
Labels

Comments

@WaylonOKC
Copy link

Issue Description

In Sequelize v5, my instance would look like:

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
}

In Sequelize v6, I do not have the _modelOptions. How can I get the model information (_modelOptions)? It's needed because the instance could be one of several different models.

StackOverflow / Slack attempts

StackOverflow Question

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
  • I don't know.

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@sushantdhiman
Copy link
Contributor

Use instance.constructor.options

@WaylonOKC
Copy link
Author

Thanks!

@jalopez526
Copy link

Use instance.constructor.options

Have this been written on docs? I spent some hours looking for something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants