解析Heroku迁移(MongoLab):PFRelation问题 [英] Parse to Heroku migration (MongoLab): PFRelation issue

查看:254
本文介绍了解析Heroku迁移(MongoLab):PFRelation问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地使用mongolab将parse移植到parse-server。现在一切都按预期工作,除了当我使用MongoLab使用PFUser进行日志记录时,我的PFRelation对象始终为空。



在我的AppDelegate中,当我运行此代码Parse):

  [解析setApplicationId:@xxxxxx
clientKey:@xxxxxx];
[PFUser enableRevocableSessionInBackground];

HomeView.m:

  self.currentUser = [PFUser currentUser]; 
self.friendsRelation = [[PFUser currentUser] objectForKey:@friends];
NSLog(@%@,self.currentUser);
NSLog(@%@,self.friendsRelation);

登录后,我的HomeView登录:

  2016-02-28 23:25:38.756 ChillN [4131:57119]< PFUser:0x7fe0b3e4fc10,objectId:MZdPHaqByR,localId:(null)> {
friends =< PFRelation:0x7fe0b3e4f900,0x7fe0b3e4fc10.friends - > _User>;
phone =06 19 05 39 30;
surname = a;
username = a;
}
2016-02-28 23:25:38.756 ChillN [4131:57119]< PFRelation:0x7fe0b3e4f900,0x7fe0b3e4fc10.friends - > _user>

所以一切正常。



mongolab db:

AppDelegate:

  [解析initializeWithConfiguration:[ ParseClientConfiguration configurationWithBlock:^(id< ParseMutableClientConfiguration>配置){
configuration.applicationId = @xxxxxxx;
configuration.clientKey = @xxxxxxx;
configuration.server = @http://xxxxxxx.herokuapp.com/parse/;
}]];

在我登录后,我的HomeView登录了这个:

  2016-02-28 23:29:21.785 ChillN [4281:59046]< PFUser:0x7fa43c09ed20,objectId:MZdPHaqByR,localId:(null)> {
phone =06 19 05 39 27;
surname = a;
username = a;

2016-02-28 23:29:21.786 ChillN [4281:59046](null)

对于日志记录,我只是使用:

  [PFUser logInWithUsernameInBackground:user 
password :密码块:^(PFUser * user,NSError * error){}];

以下是我的db:
解析:



Heroku(MongoLab):


以下是MongoLab的用户记录:

  {
_id:MZdPHaqByR,
_perishable_token:SHuhtWl0EoxxmNLOkspmp1vBF,
用户名:a,
phone:06 19 05 39 27,
surname:a ,
_session_token:zO2drjzrO0To1q0JiohaL8f4v,
_hashed_pa​​ssword:$ 2a $ 10 $ a7j5yB7uFDtv.YnHESVJgO9Io.nci8hbx7vngOo.FyzA3qBLxw38G,
_created_at:{
$日期:2016-02-28T21:55:48.548Z
},
_updated_at:{
$ date:2016-02-28T22:03:45.704Z
}
}


解决方案

这只是我的代码中的一个错误,我不得不更换: pre> self.friendsRelation = [[PFUser currentUser] objectForKey:@friends];

  self.friendsRelation = [[PFUser currentUser] relationForKey:@friends]; 

希望这会对另一个有帮助。干杯!

I succeeded to migrate parse to parse-server with mongolab. Now everything works as expected, except when I'm logging with PFUser with MongoLab, my PFRelation object is always null.

In my AppDelegate, when I run this code (official Parse):

[Parse setApplicationId:@"xxxxxx"
              clientKey:@"xxxxxx"];
[PFUser enableRevocableSessionInBackground];

HomeView.m:

self.currentUser = [PFUser currentUser];
self.friendsRelation = [[PFUser currentUser] objectForKey:@"friends"];
NSLog(@"%@", self.currentUser);
NSLog(@"%@", self.friendsRelation);

After login, my HomeView log this:

2016-02-28 23:25:38.756 ChillN[4131:57119] <PFUser: 0x7fe0b3e4fc10, objectId: MZdPHaqByR, localId: (null)> {
    friends = "<PFRelation: 0x7fe0b3e4f900, 0x7fe0b3e4fc10.friends -> _User>";
    phone = "06 19 05 39 30";
    surname = a;
    username = a;
}
2016-02-28 23:25:38.756 ChillN[4131:57119] <PFRelation: 0x7fe0b3e4f900, 0x7fe0b3e4fc10.friends -> _User>

So everything's right.

Now with the mongolab db:

AppDelegate:

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
    configuration.applicationId = @"xxxxxxx";
    configuration.clientKey = @"xxxxxxx";
    configuration.server = @"http://xxxxxxx.herokuapp.com/parse/";
}]];

After my login, my HomeView log this:

2016-02-28 23:29:21.785 ChillN[4281:59046] <PFUser: 0x7fa43c09ed20, objectId: MZdPHaqByR, localId: (null)> {
    phone = "06 19 05 39 27";
    surname = a;
    username = a;
}
2016-02-28 23:29:21.786 ChillN[4281:59046] (null)

For logging, I'm just using:

[PFUser logInWithUsernameInBackground:user
                                 password:password block:^(PFUser *user, NSError *error) {}];

Here are my db: Parse:

Heroku (MongoLab):

Here is a record for User from MongoLab:

{
    "_id": "MZdPHaqByR",
    "_perishable_token": "SHuhtWl0EoxxmNLOkspmp1vBF",
    "username": "a",
    "phone": "06 19 05 39 27",
    "surname": "a",
    "_session_token": "zO2drjzrO0To1q0JiohaL8f4v",
    "_hashed_password": "$2a$10$a7j5yB7uFDtv.YnHESVJgO9Io.nci8hbx7vngOo.FyzA3qBLxw38G",
    "_created_at": {
        "$date": "2016-02-28T21:55:48.548Z"
    },
    "_updated_at": {
        "$date": "2016-02-28T22:03:45.704Z"
    }
}

解决方案

It was just a mistake in my code, I had to replace:

self.friendsRelation = [[PFUser currentUser] objectForKey:@"friends"];

to

self.friendsRelation = [[PFUser currentUser] relationForKey:@"friends"];

Hope that will help another one. Cheers!

这篇关于解析Heroku迁移(MongoLab):PFRelation问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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