pg-promise
Version:
PostgreSQL via promises
44 lines (37 loc) • 1 kB
JavaScript
'use strict';
/**
* @constructor ConnectionContext
* @private
* @summary Connection context object.
* @param {Object} cn
* @param {} dc
* @param {Object} options
* @param {Object} db
* @param {Number} txLevel
*/
function ConnectionContext(cn, dc, options, db, txLevel) {
this.cn = cn; // connection details;
this.dc = dc; // database context;
this.options = options; // library options;
this.db = db; // database session;
this.txLevel = txLevel; // transaction level;
this.connect = function (db) {
this.db = db;
};
this.disconnect = function () {
if (this.db) {
this.db.done();
this.db = null;
}
};
this.clone = function () {
return new ConnectionContext(this.cn, this.dc, this.options, this.db, this.txLevel);
};
}
/**
* Connection Context
* @module context
* @author Vitaly Tomilov
* @private
*/
module.exports = ConnectionContext;