我在for循环中使用了一个函数。我无法导出函数的结果。
我想将结果导出到数据数组。我该怎么办?
function opPerformance(callback) {
var data = [];
dbConn.connect(function(err) {
var request = new sql.Request(dbConn);
request.query('select * from Kullanici ORDER BY Kullanici_Adi ASC ').then(function(recordset) {
var results = [];
for (var i in recordset.recordset) {
data[i] = {
kullanici_adi:recordset.recordset[i].Kullanici_Adi,
performance:'0'
};
opPerformanceData(recordset.recordset[i].Kullanici_Adi, function ( result ){
data[i]['performance'] = result; // This is not working, I can not get the end out.
console.log(result); // This works.
});
}
callback(data);
});
});
};