【问题标题】:AfterSave on PFUser checking if on creation or updateAfterSave on PFUser 检查是否在创建或更新
【发布时间】: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


    【解决方案1】:

    这似乎是未解析的 Parse 云bug

    可能的解决方法是检查创建和更新时间之间的差异,以查看您的对象是正在更新还是正在创建。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 2013-08-27
      • 2016-08-01
      • 2018-05-21
      • 2012-10-09
      相关资源
      最近更新 更多