javascript - 解析服务器云异步函数不返回结果
问题描述
我有一个应该返回的异步函数,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}")
}
异步功能可能有什么问题?
解决方案
我试图在解析服务器版本中实现异步函数2.8.2
但失败但当我更新到最新版本时,我的异步函数现在返回预期结果。
要将所有过时的模块(包括 parse-server)更新到最新版本,可以使用以下命令。-g
表示全局模块。可以省略只更新过时的本地模块
npm i -g npm-check-updates && ncu -u && npm i
推荐阅读
- javascript - how can i choose form select tag according the choice of other select tage?
- php - Laravel multiple Segments, auto generating links
- java - Spring MVC 如何将 Java 对象从 Oracle DB 转换为 jsonarray
- python - How to remove the duplicates from a multidimensional list with mutliple types in list
- c - c programming if else statements
- java - Content Resolver is null when called by second Application
- android - should i avoid long chained expresion in kotlin?
- operating-system - CPU scheduling Decisions
- python-3.x - Speech to text app: Count number of specific words said in microphone in real-time
- python - 尝试使用 tkinter 提高动画速度时出现 TypeError