How to filter items by a field in Firebase?

时间:2019-06-01 14:00:28

标签: java android firebase

"Products" : {
    "DateTime" : {
      "category" : "Mobile Phones",
      "pid" : "",
      "pname" : "",
      "price" : "",
    }
  } 

Hello I am developing an android app using firebase. I am able to list all products in my firebase database. However, I would like to show products based on the category (ex: Mobile Phones, Tablets etc). How do I do this?

1 个答案:

答案 0 :(得分:0)

you can use a compound query like:

Query products = db.collection("Products/DateTime").whereEqualTo("category", YOUR_CATEGORY);

Check more here