0

I'm working on a mini social network app were the current user can follow other friends and can see all his friend's posts.

For the following I've create a class in Parse.com were there is the followerId (which is the current user) and the followedId( (which is the friend he is following).

In the second activity I want to show only the posts of the followed friends. I already have a class with the published posts of all the users with writerId (the Id of the post's publisher) and the post (which is only a string)

My idea is to retrieve an array string containing only the followed users using This line with the following class :

pQuery.whereEqualsTo("followerId", ParseUser.getCurrentUser().getObjectId());

I don't know how to convert the query to array string.

postsQuery.whereContains("writerId", array string);

And after this querying the friend's id that are present in the array string.

I don't know if there is a best way to show the posts of only the friends I follow, but in my way I can't convert the querying ids in a string array and compare them with the writer Id column.

Abhinav singh
  • 1,448
  • 1
  • 14
  • 31
Bensaad
  • 45
  • 1
  • 7
  • Your are thinking too much in terms of relational database modeling. Your solution will not scale if you get loads of followers and followings. You need to optimise for speedy lookups and not for data normalization. Create separate tables for followings so you can easily get all followers with a simple query. See my answer here for more info: http://stackoverflow.com/a/22449103/1485715 – Marius Waldal Nov 19 '15 at 10:44
  • Hi, thanks for the repond but I didn't really understand how to use this way on my app. You are talking about adding two classes one for the followers and the second for the following, but only one is needed because a user is a follower and a following in the same time so he can be on both columns (followers only one time, and following in each array of the user is following him). – Bensaad Nov 19 '15 at 14:13
  • Take a look at the Anypic tutorial app on Parse. They have another way of handling this. You should be able to reuse a lot of the code. – Marius Waldal Nov 20 '15 at 07:34
  • I did but it's for iOS, i'm looking for Android codes, I tried to compare with other codes to understand some iOS lines but it was a fail, thank you any way for your help :) – Bensaad Nov 20 '15 at 11:29
  • I think i just found the solution in the Parse.com guide, in the relations, there is something about following followers :) – Bensaad Nov 20 '15 at 19:34

0 Answers0