subasa
subasa

Reputation: 289

Android Parse - Fetch parse objects for list of object ids

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?

Upvotes: 1

Views: 584

Answers (2)

Adham Goussous
Adham Goussous

Reputation: 71

    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 {
                // 
            }
        }
    });

Upvotes: 1

Molefe
Molefe

Reputation: 32

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

Upvotes: 0

Related Questions