0

Can anyone convert below query to firebase query in Android. I am familiar with firebase but did not know how to use it with multiple where clause

public static ParseQuery<ParseUser> getSearchSurvivorQuery(String keyword) {
    ParseQuery<ParseUser> query1 = ParseUser.getQuery();
    query1.whereContains(DbConstants.NAME, keyword);
    query1.whereNotEqualTo(DbConstants.TYPE,
            Constants.USER_TYPE.SUPPORTER.ordinal());
    query1.whereNotEqualTo(DbConstants.ID, ParseUser.getCurrentUser()
            .getObjectId());
    query1.whereNotEqualTo(DbConstants.VISIBILITY, Constants.PRIVATE);
    query1.whereNotEqualTo(DbConstants.DEACTIVATED, true);

    ParseQuery<ParseUser> query2 = ParseUser.getQuery();
    query2.whereContains(DbConstants.NAME_LOWERCASE, keyword.toLowerCase());
    // query2.whereEqualTo(DbConstants.TYPE,
    // Constants.USER_TYPE.SURVIVOR.ordinal());
    query1.whereNotEqualTo(DbConstants.TYPE,
            Constants.USER_TYPE.SUPPORTER.ordinal());
    query2.whereNotEqualTo(DbConstants.ID, ParseUser.getCurrentUser()
            .getObjectId());
    query2.whereNotEqualTo(DbConstants.VISIBILITY, Constants.PRIVATE);
    query2.whereNotEqualTo(DbConstants.DEACTIVATED, true);

    List<ParseQuery<ParseUser>> queries = new ArrayList<ParseQuery<ParseUser>>();
    queries.add(query1);
    queries.add(query2);

    ParseQuery<ParseUser> mQuery = ParseQuery.or(queries);

    return mQuery;
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Ekta Dushanj
  • 119
  • 2
  • 5
  • The Firebase Database can only order/filter on a single property. In some cases it may be possible to merge the values you want to filter on into a single property to accomplish what you want. See for more my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jul 10 '17 at 14:02

1 Answers1

0

you can't do multiple query on different child it can be done on single child , you have to filter from list of data. check this question's answer Query based on multiple where clauses in firebase

karthik
  • 347
  • 1
  • 9