forked from mariadb-corporation/mariadb-connector-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
promise.js
30 lines (25 loc) · 926 Bytes
/
promise.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
const Connection = require('./lib/connection');
const PoolPromise = require('./lib/pool-promise');
const PoolCluster = require('./lib/pool-cluster');
const ConnOptions = require('./lib/config/connection-options');
const PoolOptions = require('./lib/config/pool-options');
const PoolClusterOptions = require('./lib/config/pool-cluster-options');
module.exports.createConnection = function createConnection(opts) {
try {
const options = new ConnOptions(opts);
return new Connection(options).connect();
} catch (err) {
return Promise.reject(err);
}
};
module.exports.createPool = function createPool(opts) {
const options = new PoolOptions(opts);
const pool = new PoolPromise(options, false);
pool.initialize();
return pool;
};
module.exports.createPoolCluster = function createPoolCluster(opts) {
const options = new PoolClusterOptions(opts);
return new PoolCluster(options);
};