How to get specific collection in Firestore?

aldi nugraha :

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 :

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:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=135229&siteId=1