This commit is contained in:
aozhiwei 2023-08-21 17:02:15 +08:00
parent 5cfce23600
commit 14c3f754d1

View File

@ -65,23 +65,6 @@ class Session {
return utils.jsonEncode(this.req.query);
}
async getMarketDb() {
const idx = 0;
const dbKey = 'MarketDb' + idx;
if (this.useConns[dbKey]) {
return this.useConns[dbKey];
}
const {err, conn} = await app.getDbConn(dbKey);
if (err) {
console.log(err);
}
//console.log(new Error().stack);
if (!err && conn) {
this.useConns[dbKey] = conn;
}
return conn;
}
createModel(name) {
return modelsFactory.create(name, this);
}
@ -106,23 +89,6 @@ class Session {
return metaFactory[name](this, ...args);
}
async marketConn(method, ...args) {
const conn = await this.getMarketDb();
const ret = await conn[method](...args);
if (ret.err){
this.throwError(500, 'internal error');
log.error(ret.err);
return;
}
if (utils.hasKey(ret, 'row')) {
return ret['row'];
} else if (utils.hasKey(ret, 'rows')) {
return ret['rows'];
} else {
return null;
}
}
}
module.exports = Session;