callback.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const pkg = require('./package.json')
  3. require('please-upgrade-node')(pkg)
  4. const ConnectionCallback = require('./lib/connection-callback');
  5. const PoolClusterCallback = require('./lib/pool-cluster-callback');
  6. const PoolCallback = require('./lib/pool-callback');
  7. const ConnOptions = require('./lib/config/connection-options');
  8. const PoolOptions = require('./lib/config/pool-options');
  9. const PoolClusterOptions = require('./lib/config/pool-cluster-options');
  10. module.exports.version = require('./package.json').version;
  11. module.exports.SqlError = require('./lib/misc/errors').SqlError;
  12. module.exports.createConnection = function createConnection(opts) {
  13. return new ConnectionCallback(new ConnOptions(opts));
  14. };
  15. exports.createPool = function createPool(opts) {
  16. const options = new PoolOptions(opts);
  17. const pool = new PoolCallback(options);
  18. pool.initialize();
  19. return pool;
  20. };
  21. exports.createPoolCluster = function createPoolCluster(opts) {
  22. const options = new PoolClusterOptions(opts);
  23. return new PoolClusterCallback(options);
  24. };