pool.js
1.21 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var mysql = require('mysql'),
PoolConnection = require('./poolConnection.js'),
promiseCallback = require('./helper').promiseCallback;
var pool = function(config) {
this.pool = mysql.createPool(config);
};
pool.prototype.getConnection = function getConnection() {
return promiseCallback.apply(this.pool, ['getConnection', arguments])
.then(function(con) {
return new PoolConnection(con);
});
};
pool.prototype.releaseConnection = function releaseConnection(connection) {
//Use the underlying connection from the mysql-module here:
return this.pool.releaseConnection(connection.connection);
};
pool.prototype.query = function(sql, values) {
return promiseCallback.apply(this.pool, ['query', arguments]);
};
pool.prototype.end = function(data) {
return promiseCallback.apply(this.pool, ['end', arguments]);
};
pool.prototype.release = function(data) {
return promiseCallback.apply(this.pool, ['release', arguments]);
};
pool.prototype.escape = function(value) {
return this.pool.escape(value);
};
pool.prototype.escapeId = function(value) {
return this.pool.escapeId(value);
};
pool.prototype.on = function(event, fn) {
this.pool.on(event, fn);
};
module.exports = pool;