1
我很努力解决这个问题,因为我是Promises的新手。问题构建循环中的承诺
我需要首先读无论从火力地堡的Summative
和Formative
之前我可以确定StudentPlacement
方式下面的代码,提供null
作为StudentPlacement snapshot.val()
,因为它是不等待x
和y
值。
exports.boxScoresUpdate = functions.database.ref('/Tests/{id}/TestScores').onWrite(event => {
let testScr = 0;
for (let i = 1; i <= section; i++) {
//
testScr += parseInt(nValue[i]);
var xIndex = 0;
var yIndex = 0;
admin.database().ref('TestScores').child(data.key).child('Summative').child(i).once("value").then(x => {
xIndex = x.val();
});
admin.database().ref('TestScores').child(data.key).child('Formative').child(i).once("value").then(y => {
yIndex = y.val();
});
admin.database().ref('StudentPlacement').child(data.key).child(xIndex + ":" + yIndex).once("value", snapshot => {
// SnapShot
console.log("Student Placement is: ", snapshot.val());
});
}
}
谁能帮我构建了扳机!?
感谢您对此提供的帮助......它工作的非常好,正如我设想的那样正常工作! – Learn2Code