Answer the question
In order to leave comments, you need to log in
What to write in sequelize model?
Greetings, due to the lack of knowledge, I ran into a problem. I have a table in mysql and it has a 'side' column and it has a stupid 'enum('buy', 'sell')'. I'm creating a table model and don't know what to write in my model's form. I create a model for sequelize. Please tell me what to write type.
Answer the question
In order to leave comments, you need to log in
In a model
in migration
type: DataTypes.ENUM("foo",'bar")
type: Sequelize.ENUM("foo",'bar")
I do not know if my answer will help, but enum accepts several valid values from which either the first or second value is selected, and so on. There can be more than two values. For example ENUM('value 1', 'value 2').
In the model try to write:
side: {
type: Sequelize.ENUM('buy', 'shell'),
default: 'buy' // можно указать значение по default'у
}
status: {
type: Sequelize.ENUM("pending", "cancelled", "paid"),
defaultValue: "pending"
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question