I have over 2000 Products in Realtime DB. You can see the Product structure below
But the Problem is that I need to query with 3 WHERE clauses.
I need to get a Item WHERE CID = C09 && MID= S03 && SID= S03
I have referred the below question Query based on multiple where clauses in firebase
I have worked on the first solution. But Category C09 has over 1000 products. I am downloading 1000 products to show 20 products.
I tried using Querybase. But it has an issue.
So please suggest me an effective solution to query effectively.
CODE
var firstCat = firebase.database().ref('S01/Products').orderByChild("productCID").equalTo("C09");
  firstCat.once("value")
    .then(function (snapshot) {
      snapshot.forEach(function (childSnapshot) {
        var key = childSnapshot.key;
        var MID = childSnapshot.child("productMID").val();
        var SID = childSnapshot.child("productSID").val();
         if (MID == "M03" && SID == "S03") {
          var ProductID = childSnapshot.child("productID").val();
          var name = childSnapshot.child("productName").val();
          var unit = childSnapshot.child("productUnit").val();
          var status = childSnapshot.child("productStatus").val();
          var productMRP = childSnapshot.child("productMRP").val();
          var price = childSnapshot.child("productSellingPrice").val();
          var buying_price = childSnapshot.child("productBuyingPrice").val();
         }
      });
    });
