【发布时间】:2016-01-17 08:25:13
【问题描述】:
我很难区分 PFUser 是正在更新还是第一次保存。我实现了在 parse.com here 上找到的解决方案。但是,它不像链接中的答案中所解释的那样工作。无论它是在创建还是更新,我总是得到一个错误。这是我实现的代码。
Parse.Cloud.afterSave(Parse.User, function(request) {
Parse.Cloud.useMasterKey();
//this error log prints false regardless of if the user is signing up.
// or having a key updated.
console.error(request.object.existed());
if (!request.object.existed()) {
//This is on sign up, the user has not existed prior.
//This doesn't work. This block of code is always run.
}
else {
//This is supposedly when the user is having a key updated.
//Unfortunately, this code is never run regardless.
}
)}
此代码的行为与我预期的不同,因为 request.object.existed() 总是返回 false。我认为这可能是为了保存PFUser 而不是一些通用的PFObject。我在 PFUser afterSave 上使用 request.object.existed() 时有什么遗漏吗?谢谢。
【问题讨论】:
标签: javascript ios swift parse-platform parse-cloud-code