0
votes

I am building a social network application using parse which have follow/unfollow feature.

I have two tables: Users and Follow table.

Users table have user related data and Follow table have two fields: followerId and followedId.

I have a list of searched users. So, corresponding to each user i just want to get from query that whether i am following him/her or not. So, how to run query inside a loop?

Any help will be deeply appreciated.

Thanks.

1
You can achieve this by fetching all user list in loop. When you found all the searched users then you can run the query in the second loop. - Mamta Kaundal

1 Answers

0
votes

For get follower

ParseQuery query = new ParseQuery("FollowTable");
query.whereEqualTo("followedId", ParseUser.getCurrentUser().getObjectId());
query.findInBackground(new FindCallback() {
    public void done( List<ParseObject> MyList, ParseException e) {

        if (e == null) {
            // Get your follower user list

        }else{
            //error
        }

For get following

ParseQuery query = new ParseQuery("FollowTable");
query.whereEqualTo("followerId", ParseUser.getCurrentUser().getObjectId());
query.findInBackground(new FindCallback() {
    public void done( List<ParseObject> MyList, ParseException e) {

        if (e == null) {
            // Get your following user list

        }else{
            //error
        }

Then after call user list query in ParseUser table and get all the user. Thanks