2

enter image description here How I can get all collection with level==2 and status==on, order by count? And limit only the first collection that I can get. And how can i get the collection value? I need to get the collection and store it since I need it for other function.

I already read Firestore documentation a few times now, but I still cant find the way to do this.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
aldi nugraha
  • 105
  • 8

1 Answers1

1

How i can get all collection with level==2 and status=="on", order by count?

You cannot get all collections, you can get all documents with that constraint within that collection. The query that you are looking for is:

db.collection("User").whereEqualTo("level", 2).whereEqualTo("status", true).limit(1);

But rememeber, everytime you are using such a query, an index is required. For that, please see my answer from the following post:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193