MCPcopy
hub / github.com/sequelize/sequelize / useCLS

Method useCLS

src/sequelize.js:1223–1232  ·  view source on GitHub ↗

* Use CLS (Continuation Local Storage) with Sequelize. With Continuation * Local Storage, all queries within the transaction callback will * automatically receive the transaction object. * * CLS namespace provided is stored as `Sequelize._cls` * * @param {object} ns CLS namespace

(ns)

Source from the content-addressed store, hash-verified

1221 * @returns {object} Sequelize constructor
1222 */
1223 static useCLS(ns) {
1224 // check `ns` is valid CLS namespace
1225 if (!ns || typeof ns !== 'object' || typeof ns.bind !== 'function' || typeof ns.run !== 'function') throw new Error('Must provide CLS namespace');
1226
1227 // save namespace as `Sequelize._cls`
1228 Sequelize._cls = ns;
1229
1230 // return Sequelize for chaining
1231 return this;
1232 }
1233
1234 /**
1235 * Run function in CLS context.

Callers 3

cls.test.jsFile · 0.80
sequelize.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected