我已经安装了parse-server-example并且已经上传了我的云代码。我在那里有一个函数,但收到错误响应。成功是没有函数。
Parse.Cloud.define("submitWeeklyScore", function (request, response) {
const gameScore = new Parse.Object("WeeklyGameScore");
gameScore.set("id", request.params.id);
gameScore.set("score", request.params.score);
gameScore.set("name", request.params.name);
gameScore.set("family", request.params.family);
gameScore.set("username", request.params.username);
gameScore.save(null, {useMasterKey: true}).then((saveResult) => {
var playerScore = saveResult.get("score");
var playerCreatedAt = saveResult.createdAt;
var objectId = saveResult.id;
var mainQuery = new Parse.Query("WeeklyGameScore");
mainQuery.greaterThanOrEqualTo("score", playerScore);
mainQuery.lessThan("createdAt", playerCreatedAt);
mainQuery.count({useMasterKey: true}).then((count) => {
var obj = {rank: count + 1, objId: objectId};
response.success(obj);
}, (error) => {
response.error(error);
});
}, (error) => {
response.error(error);
});
});
如果我替换response.success(obj);与返回对象;我明白了:
info: Ran cloud function submitWeeklyScore for user undefined with:
Input: {"score":1337,"rubikaId":11111,"name":"","family":"","username":""}
Result: undefined {"functionName":"submitWeeklyScore","params": {"score":1337,"rubikaId":11111,"name":"","family":"","username":""}}
该对象将被保存,没有任何问题,但是没有结果。
答案 0 :(得分:0)
“解析服务器”示例将安装最新版本的解析服务器。 Parse Server的3.0.0版删除了response.success()。有关更新您的云代码的详细信息,请参见migration guide。