简体   繁体   English

Parse.com-来自PFUser对象的电子邮件尽管价值不菲

[英]Parse.com - email from PFUser object fetches a nil despite having value

I have a query "items" object. 我有一个查询“项目”对象。 The class has a "parent" key that points to _User object. 该类具有指向“ _User”对象的“父”键。

The query is successful and fetches 'parent' object and i am able to access some custom keys from this 'parent' object but email is returned as nil !! 查询成功并获取“父”对象,我能够从该“父”对象访问一些自定义键,但电子邮件返回为nil! below is stripped down code. 下面是精简的代码。

Could anyone suggest why is this happening? 有人可以说为什么会这样吗? This was working earlier and i have not made any code change. 这是较早的工作,我没有做任何代码更改。 Running Parse-server ver 2.5.3 on Heroku. 在Heroku上运行Parse-server 2.5.3版。

     let query = PFQuery(className: "items")
     query.includeKey("parent") // parent points to _User


     do {

         let results = try query.findObjects()

         for result in results {

         let parent = result["parent"] as! PFUser

        let foundUser = User()
        foundUser.user = parent // User.user is of PFUser type

        //custom keys in _User
        foundUser.name = parent["name"] as! String 
        foundUser.city = parent["city"] as! String
        foundUser.geoLocation = parent["location_geopoint"] as! PFGeoPoint 
        foundUser.userAddress = parent["user_address"] as! String

        //this is failing with nil eventhough there is value in Parse
        foundUser.email = parent["email"] as! String

        // also tried this. parent.objectId returns a valid value
        foundUser.email = parent.email


       }

     } catch...

Got the answer here enter link description here 在这里得到答案在这里输入链接描述

In 2.3.0 there was a breaking change introduced which restricted the fields returned from a query on _User. 在2.3.0中,引入了一项重大更改,该更改限制了_User查询返回的字段。 If I remember correctly, email is taken out by default and you can specify additional fields to be removed from a query result in a configuration setting. 如果我没记错的话,默认情况下会删除电子邮件,您可以在配置设置中指定要从查询结果中删除的其他字段。 In order to retrieve email you either have to specify the master key or be the owner of that object. 为了检索电子邮件,您必须指定主密钥或成为该对象的所有者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM