feat: test psql without defineProperty (#7815)

* feat: test psql without defineProperty

* feat: refactor psql

remove .bind calls, use module.pool.query directly
move requires to top of file
move promisify to bottom so .init etc are promisified

* feat: mongodb

move requires to bottom

* feat: redis
This commit is contained in:
Barış Soner Uşaklı
2019-08-05 09:20:00 -04:00
committed by GitHub
parent 52a2e5d61d
commit af1f7249a7
33 changed files with 301 additions and 341 deletions

View File

@@ -81,37 +81,11 @@ postgresModule.init = function (callback) {
}
postgresModule.pool = db;
Object.defineProperty(postgresModule, 'client', {
get: function () {
return db;
},
configurable: true,
});
var wrappedDB = {
connect: function () {
return postgresModule.pool.connect.apply(postgresModule.pool, arguments);
},
query: function () {
return postgresModule.client.query.apply(postgresModule.client, arguments);
},
};
postgresModule.client = db;
checkUpgrade(client, function (err) {
release();
if (err) {
return callback(err);
}
require('./postgres/main')(wrappedDB, postgresModule);
require('./postgres/hash')(wrappedDB, postgresModule);
require('./postgres/sets')(wrappedDB, postgresModule);
require('./postgres/sorted')(wrappedDB, postgresModule);
require('./postgres/list')(wrappedDB, postgresModule);
require('./postgres/transaction')(db, postgresModule);
postgresModule.async = require('../promisify')(postgresModule, ['client', 'sessionStore', 'pool', 'transaction']);
callback();
callback(err);
});
});
};
@@ -455,3 +429,12 @@ postgresModule.socketAdapter = function () {
pubClient: postgresModule.pool,
});
};
require('./postgres/main')(postgresModule);
require('./postgres/hash')(postgresModule);
require('./postgres/sets')(postgresModule);
require('./postgres/sorted')(postgresModule);
require('./postgres/list')(postgresModule);
require('./postgres/transaction')(postgresModule);
postgresModule.async = require('../promisify')(postgresModule, ['client', 'sessionStore', 'pool', 'transaction']);