I have a Firebase (NoSQL) collection of say 5,000 "players". Each day I want to query a subset of those players in order to perform some operation. My question is, what is the best way to do that?
As best as I can tell, there is no way to perform such a query within Firebase directly. So for example, I cannot say "Collection of 5,000 players, give me all of the players which match ANY of these identifiers". If that is an option, please advise.
One option I thought of would be to create a new collection each day with the identifiers of players I am interested in performing operations on. Would this be the preferred method in Firebase? IE, I'd create a collection like 20190105Game
and it would contain the identifier subset. I'd query that collection first, then go to the Players
collection to get collection.where("identifier", "==", "other_identifier")
Is there a better way?
If you want to filter a subset of the players, you have two options:
Include the condition for the subset into your query. Eg playersRef.where("subset", "=", 2).where("othercondition", "=", "value").orderBy("somefield").limit(2)
Create a (sub)collection for the subset of players.
Neither is pertinently better than the other, it all depends on your exact use-cases. I'd typically go for the first option, unless I have a use-case where tht is impossible due to my other query or throughput requirements.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.