1

I have an ArrayList of userIds and I want to fetch every user where userId is in that ArrayList. I don't want to use for loop and to make request for every userId in the list. Is there an option to send ArrayList as a parameter and to get list of ParseObjects as a response?

5
  • what do u mean by not using a for loop? Commented Oct 20, 2015 at 7:59
  • 1
    and from where do you want to fetch users? from a backend server? from your local db? Commented Oct 20, 2015 at 8:01
  • I want to fetch users from a backend server Commented Oct 20, 2015 at 8:02
  • @HariKrishnan What I can do is to make request for every id that I have in the list by using for loop, but for sure there is a better way how to do this Commented Oct 20, 2015 at 8:05
  • cant u send a json which have all these ids? Commented Oct 20, 2015 at 8:13

2 Answers 2

1
    List<String> userIds = new ArrayList<>();
    ParseQuery<ParseUser> userParseQuery = ParseUser.getQuery();
    userParseQuery.whereContainedIn("objectId", userIds);
    userParseQuery.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> objects, ParseException e) {
            if (e == null){
                //  
            } else {
                // 
            }
        }
    });
Sign up to request clarification or add additional context in comments.

Comments

0

I think there's a contains() method you can use if I even understand you properly. It's been a while since I did something like that but i think it has to be overridden. for example if you have ArrayList you can override the method to take an object of person as a parameter and compare a few fields of the person object then return a boolean or something like that. bus since you don't want to use a for loop then I guess you will just have to use a for-each loop then

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.