cls-mysql
Version:
Continuation local storage shim for MySQL
28 lines (20 loc) • 933 B
Markdown
[][] provides a shim layer for [node-mysql][] so that it will
work with [continuation-local-storage][]. It does this by binding all
callbacks that are passed into node-mysql with a CLS namespace.
```js
var cls = require('continuation-local-storage');
var ns = cls.createNamespace('NODESPACE');
var mysql = require('mysql');
// load shim
require('cls-mysql')(ns);
```
The tests assume that a MySQL server is running on localhost, and the
user `root` can login without password. Alternate database config can
optionally be provided in `test/config.js`. See the
[][] for config options for MySQL connections.
[]: https://www.npmjs.com/package/cls-mysql
[]: https://www.npmjs.com/package/mysql
[]: https://www.npmjs.com/package/continuation-local-storage
[]: https://github.com/felixge/node-mysql/#connection-options