我创建了一条路线:
var connexion = require('./dbMysql');
exports.getPrefixNomTables = function () {
return "george_";
};
exports.getRegionIdFromLib = function (regionLib, cb) {
var ret = 0;
connexion.query("select region_id from george_region where region_libelle = ? limit 1", [regionLib], (err, rows) => {
if (err) {
throw err;
}
if (rows.length > 0)
ret = rows[0].region_id;
cb(ret);
});
};
在getRegionIdFromLib
函数中,我想调用getPrefixNomTables
方法,而不是对george_region
进行硬编码。该怎么做?
答案 0 :(得分:1)
您可以在exports.getPrefixNomTables()
内致电getRegionIdFromLib
:
exports.getRegionIdFromLib = function (regionLib, cb) {
var region = exports.getPrefixNomTables()
// ...
};