Search code examples
javaandroidparse-platform

How to use multiple query constraints in Parse


I'm trying to sort through ParseObjects created by different users (clubadmins) and presenting the results based on "clubAdmin" in a recyclerview. For some reason I can't put my finger on, the query is not yielding any results to populate my view. The line that seems to be the problem is where I query to sort using whereEqualTo(). Any help with what might be the problem is much appreciated.

The .toString() was the latest addition which also did not resolve the issue.

ParseQuery<Club> query = ParseQuery.getQuery(Club.class);     
query.whereEqualTo("clubAdmin",ParseUser.getCurrentUser().toString());
query.orderByAscending("createdAt");
query.setLimit(MAX_CLUBS_TO_SHOW);
query.findInBackground(new FindCallback<Group>() {
            @Override
            public void done(List<Club> objects, ParseException e) {
                if(e == null) {
                    for (Club c : objects) {
                        Club createdClub = new Club();
                        createdClub.setClubName(c.getClubName());
                        createdClub.setObjectId(c.getObjectId());

                        listItems.add(createdClub);

I was aiming for a list with the clubs created by the logged in user barring all others. Now I do not see anything in my view. If I comment out the line containing whereEqualTo(), I get all the clubs created within the app populating my view set to the limit.


Solution

  • What is the type of clubAdmin field? Is it a pointer to user class or a String holding the objectId of a user? If it is the second case, you have to get the objectId of the user like ParseUser.getCurrentUser().getObjectId();