-[FIXED] Call `conformOptions` on default scope [#4157](https://github.com/sequelize/sequelize/issues/4157)
-[FIXED] Call `conformOptions` on scopes returned by functions [#3991](https://github.com/sequelize/sequelize/issues/3991)
-[FIXED] Calling `validateIncludedElements` should not add an aliassed primary key multiple times [#4127](https://github.com/sequelize/sequelize/issues/4127)
@@ -43,6 +43,8 @@ var Project = sequelize.define('project', {
});
```
You can also add scopes after a model has been defined by calling `addScope`. This is especially useful for scopes with includes, where the model in the include might not be defined at the time the other model is being defined.
The default scope is always applied. This means, that with the model definition above, `Project.findAll()` will create the following query:
@@ -1008,6 +1008,34 @@ Model.prototype.unscoped = function () {
};
/**
* Add a new scope to the model. This is especially useful for adding scopes with includes, when the model you want to include is not available at the time this model is defined.
*
* By default this will throw an error if a scope with that name already exists. Pass `override: true` in the options object to silence this error.
*
* @param {String} name The name of the scope. Use `defaultScope` to override the default scope