0

My Database looks like this enter image description here

To get items I do this:

        mFirebaseDatabase
                        .getReference("credits")
                        .orderByChild("regionId")
                        .equalTo(2607)
                        .addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        List<Credit> creditList = new ArrayList<Credit>();

                        for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                        Credit credit = postSnapshot.getValue(Credit.class);
                        creditList.add(credit);
                         }
                    }
                });
  1. How to make query "where regionId==2607 OR regionId==0"?
  2. How to make query "where 'requiredDocuments'.contains("Passport")"?
NickUnuchek
  • 11,794
  • 12
  • 98
  • 138
  • Firebase queries can only contain a single `orderBy...()` condition. Sometimes it is possible to combine the multiple values into a single property. See http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Oct 14 '16 at 12:54
  • Firebase queries do not support text operators like `contains`. See http://stackoverflow.com/questions/28589092/firebase-query-find-item-with-child-that-contains-string – Frank van Puffelen Oct 14 '16 at 12:55
  • I am not sure, I have not tested but as far as I know firebase query does not support where clause. If you want to query objects with regionId you should restructure the data and have regionId as key and array of objects as value. – Zura Sekhniashvili Oct 15 '16 at 10:07

0 Answers0