我第一次使用Parse并使用数据浏览器。我有2个表:用户和朋友。我的应用中的每个用户都可以有50个朋友。
所以我在Parse中的数据库看起来像:
Table Users:
username (unique)
email (unique)
friends (a one to many relationship to the friends table)
Table Friends:
email
name
whoseFriend (this is many to one to one friends in the Users table)
在数据浏览器中,我将用户朋友设置为一个数组(根据Parse的文档),但是我将whatFriend设置为什么?只是一个字符串?我如何从谁的朋友那里找出父母的朋友呢?
谢谢!
答案 0 :(得分:0)
//Make it as array of dictionary. Suppose below is list of my friends "friendof" here we will show friend of friends
{
friendsList = {
friendare = (
{
friendName = {
text = a;
};
friendof = {
friendnames = (
{
text = 456;
},
{
text = 456;
}
);
};
},
{
friendName = {
text = a;
};
friendof = {
friendnames = {
text = 456;
};
};
}
);
};
}
答案 1 :(得分:0)
在数据浏览器中,我将用户朋友设置为一个数组(根据Parse的文档),但是我将whatFriend设置为什么?只是一个字符串?我如何从谁的朋友那里找出父母的朋友呢?
Parser doc说:
当我们知道我们的一对多关系中涉及的对象数量将会很小时,数组是理想的
也许您正在使用Pointer。 在你的情况下:
创建好友对象
PFObject *friend= [PFObject objectWithClassName:@"Friends"];
设置whoFriend
[friend setObject:[PFUser currentUser] forKey:@"whoseFriend"];
[PFUser currentUser]或其他用户
找出父母的朋友
PFQuery *friendQuery = [PFQuery queryWithClassName:@"Friends"];
[gameQuery whereKey:@"whoseFriend" equalTo:[PFUser currentUser]];