[英]Parse server cloud async function not returning the result
我有一個async函數應該返回true
或false
但是它已經根據日志而不是一次和結束執行了幾次但是返回了一個i/o failure
錯誤消息而不是預期的值。
Parse.Cloud.define("updateMatch", async (request) => {
const query = new Parse.Query("Match");
query.equalTo("league", request.params.league);
const results = await query.find();
var match = null;
if (results.length > 0) {
match = results[0];
}else{
var Match = Parse.Object.extend("Match");
match = new Match();
match.set("groupId", request.params.Id);
}
match.set("stadium",request.params.stadium);
var saved = await match.save(null, { useMasterKey: true });
return true;
});
當我將異步函數更改為普通函數時,它會執行一次並返回期望值,該值為true
Parse.Cloud.define("updateMatch", function(request,response){
const query = new Parse.Query("Match");
query.equalTo("league", request.params.league);
query.find().then((results)=>{
var match = null;
if (results.length > 0) {
match = results[0];
}else{
var Match = Parse.Object.extend("Match");
match = new Match();
match.set("groupId", request.params.Id);
}
match.set("stadium",request.params.stadium);
match.save(null, { useMasterKey: true });
return response.success(true);
});
});
這是我從android調用函數的方式
val params = HashMap<String, Any>()
params["league"] = "EPA"
params["groupId"] = "A"
params["stadium"] = "Etihad"
ParseCloud.callFunctionInBackground("updateMatch", params,FunctionCallback { success, e ->
AppLogger.error("success? ${success} error is ${e?.message}")
}
異步函數有什么問題?
我試圖在parse-server版本2.8.2
實現async函數失敗但是當我更新到最新版本時,我的異步函數現在返回預期的結果。
要將所有過時的模塊(包括parse-server)更新到最新版本,可以使用以下命令。 -g
表示全局模塊。 可以省略它只更新過時的本地模塊
npm i -g npm-check-updates && ncu -u && npm i
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.