* 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 = {})
| 449 | * sequelize.models.modelName class="cm">// The model will now be available in models under the name given to define |
| 450 | */ |
| 451 | define(modelName, attributes, options = {}) { |
| 452 | options.modelName = modelName; |
| 453 | options.sequelize = this; |
| 454 | |
| 455 | const model = class extends Model {}; |
| 456 | |
| 457 | model.init(attributes, options); |
| 458 | |
| 459 | return model; |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * Fetch a Model which is already defined |