* 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)
| 1139 | * @returns {object} Sequelize constructor |
| 1140 | */ |
| 1141 | static useCLS(ns) { |
| 1142 | class="cm">// check `ns` is valid CLS namespace |
| 1143 | if (!ns || typeof ns !== class="st">'object' || typeof ns.bind !== class="st">'function' || typeof ns.run !== class="st">'function') throw new Error(class="st">'Must provide CLS namespace'); |
| 1144 | |
| 1145 | class="cm">// save namespace as `Sequelize._cls` |
| 1146 | Sequelize._cls = ns; |
| 1147 | |
| 1148 | class="cm">// return Sequelize for chaining |
| 1149 | return this; |
| 1150 | } |
| 1151 | |
| 1152 | /** |
| 1153 | * Run function in CLS context. |
no outgoing calls
no test coverage detected