I am using Sequelize Typescript v6. I already have a model with a lot of features and I want to get a list of those features.
const attrs = attributes(MyModel)
console.log(attrs)
// [col0Name, col1Name, col2Name,...]
I see that Sequelize Typescript has a way to Type a list as a set of parameters for a model Getting a models attributes . But I cannot use this as a function.
const modelAttributes = Attributes<MyModel>
//'Attributes' only refers to a type, but is being used as a value here.
I tried MyModel.attributes
but that doesn't exist either. Thank you in advance for your time and help.
MyModel.getAttributes()
Also, .rawAttributes
seems to be a way as well. Is there a way to get attributes // associations by previously defined Sequelize Model?
To get a list of strings I used
const myAttrs = Object.keys(MyModel.rawAttributes)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.