0
我成功地將parse遷移到parse-server和mongolab。現在一切都按預期工作,除了當我用MongoLab記錄PFUser時,我的PFRelation對象始終爲空。解析Heroku遷移(MongoLab):PFRelation issue
在我的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分貝現在:
的AppDelegate:
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
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:password block:^(PFUser *user, NSError *error) {}];
這裏是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"
}
}