MCPcopy Index your code
hub / github.com/sequelize/sequelize / useCLS

Method useCLS

lib/sequelize.js:1141–1150  ·  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

1139 * @returns {object} Sequelize constructor
1140 */
1141 static useCLS(ns) {
1142 // check `ns` is valid CLS namespace
1143 if (!ns || typeof ns !== 'object' || typeof ns.bind !== 'function' || typeof ns.run !== 'function') throw new Error('Must provide CLS namespace');
1144
1145 // save namespace as `Sequelize._cls`
1146 Sequelize._cls = ns;
1147
1148 // return Sequelize for chaining
1149 return this;
1150 }
1151
1152 /**
1153 * Run function in CLS context.

Callers 3

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

Calls

no outgoing calls

Tested by

no test coverage detected