我正在尝试获取布尔值,但不确定。
我正在使用lodash检查mysql返回的isEmpty或Not
// app.js
const mainMySql = require('./mysql');
async () => {
const isAdrressInDB = await mainMySql.isAddressInDB(address);
console.log(isAdrressInDB); // Undefiend
};
// mysql.js
exports.isAddressInDB = (address) => {
const query = 'SELECT address FROM users WHERE address = ?';
connection.query(query, [address], (err, rows, fields) => {
result = _.isEmpty(rows[0]);
console.log('Lodash result: ', result); // True
return result;
});
};