* Define a new model, representing a table in the database. * * The table columns are defined by the object that is given as the second argument. Each key of the object represents a column * * @param {string} modelName The name of the model. The model will be stored in `sequelize.models`
(modelName, attributes, options = {})
| 460 | * sequelize.models.modelName // The model will now be available in models under the name given to define |
| 461 | */ |
| 462 | define(modelName, attributes, options = {}) { |
| 463 | options.modelName = modelName; |
| 464 | options.sequelize = this; |
| 465 | |
| 466 | const model = class extends Model {}; |
| 467 | |
| 468 | model.init(attributes, options); |
| 469 | |
| 470 | return model; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Fetch a Model which is already defined |