[sequelize] Add explanation for Model.associate? method

This commit is contained in:
Pablo Moleri
2018-05-22 11:11:11 -03:00
parent 88fc0023e6
commit acf760be0c
2 changed files with 16 additions and 0 deletions
+9
View File
@@ -4085,6 +4085,15 @@ declare namespace sequelize {
/**
* Set associations with other models
*
* Not part of the sequelize API, used as convention to associate models after creation. e.g.:
* ```js
* Object.keys(models).forEach(modelName => {
* if (models[modelName].associate) {
* models[modelName].associate(models);
* }
* });
* ```
*
* @param models
*/
associate?(models: Models): void;
+7
View File
@@ -1523,6 +1523,13 @@ s.define( 'ScopeMe', {
}
} );
// Test convention method used to associate models after creation
Object.keys(s.models).forEach(modelName => {
if (s.models[modelName].associate) {
s.models[modelName].associate(s.models);
}
});
// Generic find options
interface ChairAttributes {
id: number;