0
votes

I have the following structure in a Firestore collection. The "ranks" collection is updated with documents named after the timestamps. In each document, I have the same fields and values. How can I query all documents for a specific field without parsing the entire document? I.e. I want all values in all documents where field is "aave"?

I am new to Firestore and I've been trying this for several weeks now. I tried limiting with where and considered using sub collection group queries but in my case data is not stored in sub collections. Sorry, for not being able to provide more context, since I couldn't get much closer.

1
How many distinct values are you approximately expecting? How fast do you need the query to be? - Stratubas

1 Answers

0
votes

Queries select specific values, or ranges of values, of a known field. There is no support for dynamic field names in a query in Firestore.

But if you want to get all documents where the field aave exists/has any value, you can make use of the fact that in the sort order of values they always start with null. So to get all documents where the field aave exists/has any value, you could do:

firebase.firebase().collection("ranks").where("aave", ">=", null)