解析request.object.existed()返回false [英] Parse request.object.existed() return false

查看:114
本文介绍了解析request.object.existed()返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解析有问题。我写了云代码

I have problem with parse. I wrote cloud code

Parse.Cloud.afterSave(Parse.User, function(request) {
  var user = request.object;
  if( !user.existed() ) {
      //all the times !user.existed() is true when I save user object
      //also in signup is true
  }

})

我该如何制作如果块只在用户是新用户的情况下运行?

how can I make the inside if block run only if the user is new user?

推荐答案

这似乎是最新的Parse Javascript中的Parse bug SDK(1.6.7)。

This seems to be a Parse bug as of the latest Parse Javascript SDK (1.6.7).

https://developers.facebook.com/bugs/1675561372679121/

快速解决(上述主题中Andrei Patru提供):

A quick work around (courtesy of Andrei Patru in the above thread):

var createdAt = request.object.get("createdAt");
var updatedAt = request.object.get("updatedAt");
var objectExisted = (createdAt.getTime() != updatedAt.getTime());

刚刚测试过它就可以了。

Just tested it and it works.

这篇关于解析request.object.existed()返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆