Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how to combine two parse queries using 'OR'

I am looking to combine two parse queries into one which satisfies an 'OR' condition. How do I achieve this? The docs say that I need a list of parse queries but I am not very sure how to do that ? Here is my code :

ParseQuery<ParseUser> numberQuery = ParseUser.getQuery();
        numberQuery.whereNotEqualTo("objectId", currentUser.getObjectId());
        numberQuery.whereContainedIn("phoneNumber", values);
        ParseQuery<ParseUser> emailQuery = ParseUser.getQuery();
        emailQuery.whereNotEqualTo("objectId", currentUser.getObjectId());
        numberQuery.whereContainedIn("email", values);
        ParseQuery<ParseUser> superQuery = ParseUser.getQuery();
        superQuery.or

How do I complete this query and get the 'OR' of the two in superquery ? Thanks

like image 493
Shivam Bhalla Avatar asked Jul 12 '14 12:07

Shivam Bhalla


1 Answers

Okay I figured it out myself. To create a list you use

    List<ParseQuery<ParseUser>> queries = new ArrayList<ParseQuery<ParseUser>>();

and then

queries.add(q1);
queries.add(q2); 

and so on. And then you use

ParseQuery<ParseUser> superQuery = ParseUser.getQuery();
        ParseQuery.or(queries);

to get the final combined query.

like image 134
Shivam Bhalla Avatar answered Nov 18 '22 05:11

Shivam Bhalla