1
This commit is contained in:
parent
5cfce23600
commit
14c3f754d1
@ -65,23 +65,6 @@ class Session {
|
|||||||
return utils.jsonEncode(this.req.query);
|
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) {
|
createModel(name) {
|
||||||
return modelsFactory.create(name, this);
|
return modelsFactory.create(name, this);
|
||||||
}
|
}
|
||||||
@ -106,23 +89,6 @@ class Session {
|
|||||||
return metaFactory[name](this, ...args);
|
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;
|
module.exports = Session;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user