【发布时间】:2015-07-03 23:58:02
【问题描述】:
我在学习 Cloud Code 的第 3 天,进展甚微。我对呼叫过程的工作方式感到困惑。在 Cloud Code 中,我需要使用 afterSave 来查询一个类,其中键“sent”等于 false,并且对于接收者数组中的每个接收者,向每个接收者推送一个通知并将“发送”设置为 true。
我在 main.js 中保存了 afterSave 函数,但每次我使用 PFCloud.callFunctionInBackground() 调用它时都会得到 [Error]: function not found (Code: 141, Version: 1.7.2)。
这是我的 afterSave 触发器:
Parse.Cloud.afterSave("Send", function(request) {
query = new Parse.Query("Shares");
query.get(request.object.get("share").id, {
success: function(post) {
console.success("Howdy");
},
error: function(error) {
console.error("Got an error " + error.code + " : " + error.message);
}
});
});
我在这里用 Swift 调用函数:
PFCloud.callFunctionInBackground("Send", withParameters: nil) {
(response: AnyObject?, error: NSError?) -> Void in
let result = response as? String
println(result)
}
如果我在 saveInBackgroundWithBlock 闭包内调用 afterSave 触发器,是否使用 PFCloud.callFunctionInBackground 调用它?
【问题讨论】:
标签: javascript swift parse-platform parse-cloud-code