我有試圖更新用戶平衡,新的平衡,如果他們贏得了聯賽冠軍Parse..com雲代碼:嘗試更新用戶的列,但什麼也沒發生
此功能的輔助功能,這是一個後臺作業被正確調用,但updateUserEarnings函數中的「query.first」和updateWinningsHelper中的「then」函數永遠不會被調用,至少在log中沒有顯示任何內容。是的,我是用戶masterkey。
var updateUserEarnings = function (User,prizeValue){
//var user = new Parse.User();
console.log("updateUserEarnings Called");
console.log("User Id: " + User.id);//Shown in log fi
console.log("PrizeValue " + prizeValue);//Shown in log file
var query = new Parse.Query(Parse.User);
query.equalTo("objectId",User.id);
return query.first({
success: function(result){
console.log("updateUserEarnings success");//Never Reached here
var balance;
if (result.get("cashBalance")){
balance = result.get("cashBalance");
}else{
balance = 0;
}
console.log("Current Balance "+ balance + " for "+result.get("DisplayUsername"));
balance = balance + prizeValue;
result.set("cashBalance",balance);
console.log("User " + result.get("DisplayUsername") + " Balance Updated : " + balance);
return result
},error:function(error){
console.log("user update error "+error);//never reached here as well
return error;
}
})
}
var updateWinningsHelper = function(index,lastIndex,record){
var winningObj = record.winningObject;
console.log("Winning object "+ JSON.stringify(winningObj));//Shown in log
console.log("Index : "+index + " lastIndex : "+lastIndex);//Shown in log
if (index < lastIndex){
updateUserEarnings(winningObj.get("User"), winningObj.get("League").get("PrizeValue")).then(
function(user){
console.log("Inside then function");//Never Reached
saveAllObjects.push(user);
},
function(error){
console.log("Error Happened "+error);//never reached
}
);
winningObj.set("LeagueWon",true);
winningObj.set("isRedeemed",true);
}else{
winningObj.set("LeagueWon",false);
}
index++;
winningObj.set("Rank",index);
return winningObj;
};
任何幫助表示讚賞
謝謝,我不知道在調試時會讓你頭疼。我會牢記這一點。 –