-[ADDED] include now supports string as an argument (on top of model/association), string will expand into an association matched literally from Model.associations
-[ADDED] include now supports string as an argument (on top of model/association), string will expand into an association matched literally from Model.associations
-[FIXED] Accept dates as string while using `typeValidation`[#6453](https://github.com/sequelize/sequelize/issues/6453)
-[FIXED] Accept dates as string while using `typeValidation`[#6453](https://github.com/sequelize/sequelize/issues/6453)
-[FIXED] - ORDER clause was not included in subquery if `order` option value was provided as plain string (not as an array value)
-[FIXED] - ORDER clause was not included in subquery if `order` option value was provided as plain string (not as an array value)
-[FIXED] support for CLS with `cls-bluebird` module
# 4.0.0-1
# 4.0.0-1
-[CHANGED] Removed `modelManager` parameter from `Model.init()`[#6437](https://github.com/sequelize/sequelize/issues/6437)
-[CHANGED] Removed `modelManager` parameter from `Model.init()`[#6437](https://github.com/sequelize/sequelize/issues/6437)
To enable CLS you must tell sequelize which namespace to use by setting it as a property on the sequelize constructor:
To enable CLS you must tell sequelize which namespace to use by using a static method of the sequelize constructor:
```js
```js
varSequelize=require('sequelize');
varSequelize=require('sequelize');
Sequelize.cls=namespace;
Sequelize.useCLS(namespace);
newSequelize(....);
newSequelize(....);
```
```
Notice, that the `cls` property must be set on the *constructor*, not on an instance of sequelize. This means that all instances will share the same namespace, and that CLS is all-or-nothing - you cannot enable it only for some instances.
Notice, that the `useCLS()` method is on the *constructor*, not on an instance of sequelize. This means that all instances will share the same namespace, and that CLS is all-or-nothing - you cannot enable it only for some instances.
CLS works like a thread-local storage for callbacks. What this means in practice is, that different callback chains can access local variables by using the CLS namespace. When CLS is enabled sequelize will set the `transaction` property on the namespace when a new transaction is created. Since variables set within a callback chain are private to that chain several concurrent transactions can exist at the same time:
CLS works like a thread-local storage for callbacks. What this means in practice is that different callback chains can access local variables by using the CLS namespace. When CLS is enabled sequelize will set the `transaction` property on the namespace when a new transaction is created. Since variables set within a callback chain are private to that chain several concurrent transactions can exist at the same time:
After you've used `Sequelize.useCLS()` all promises returned from sequelize will be patched to maintain CLS context. CLS is a complicated subject - more details in the docs for [cls-bluebird](https://www.npmjs.com/package/cls-bluebird), the patch used to make bluebird promises work with CLS.
# Concurrent/Partial transactions
# Concurrent/Partial transactions
You can have concurrent transactions within a sequence of queries or have some of them excluded from any transactions. Use the `{transaction: }` option to control which transaction a query belong to:
You can have concurrent transactions within a sequence of queries or have some of them excluded from any transactions. Use the `{transaction: }` option to control which transaction a query belong to: