我在 Parse 中有 2 个表,如下所示:
Users:
(PFUsers table with all Parse data)
belongsToGroups (A Parse Relation to Groups which is many to many)
Groups:
groupId
name
groupMembers (A Parse Relation to Users which is also many to many)
我有以下代码:
PFObject *groups = [PFObject objectWithClassName:@"Groups"];
groups[@"name"] = name;
syncUsers[@"isActive"] = [NSNumber numberWithInt:1];
//[groups saveInBackground];
PFUser *current = [PFUser currentUser];
PFRelation *relation = [syncUsers relationforKey:@"groupMembers"];
[relation addObject:current];
[groups saveEventually];
PFRelation *relation2 = [current relationforKey:@"belongsToGroups"];
[relation2 addObject:groups];
[current saveEventually];
首先,前 2 个代码块工作正常,但是如何更新用户中的关系,以便我可以在 Parse 中查看关系并查看我的组?
二,我是否需要在用户和组中创建关系以便它可以是多对多的?