var cache = {};
var userId = datum.uniqueID;
mysql.query('select accountID, deviceID, uniqueID from Device WHERE uniqueID = ' + mysql.escape(userId),
function(err, result, fields) {
if (err) throw err;
else {
for (var i in result) {
var res = result[i];
cache.accountID = res.accountID;
cache.deviceID = res.deviceID;
console.log(result); //可以打印结果
console.log(cache.accountID); //可以打印结果
}
}
});
console.log(result); //无法打印结果
console.log(cache.accountID); //无法打印结果