I am curious as to the efficiency of searching for documents in a collection using this code. As the number of documents in the collection grows and the number of items in the array grows will this search become very inefficient? Is there a better way of doing this or is there a schema change I can make to the database to better optimize this? Is there somewhere I can find the time complexity of these functions for the firestore documentation maybe?
Query query = db.collection("groups").whereArrayContains("members", userid);
ALTERNATIVE SOLUTION
I originally wanted to try storing the group ids under the user so as to only grab the groups for that current user, but ran into issues and never found a solution for setting a FireStoreRecyclerOptions using multiple ids to query by.
Example:
for(String groupid : list) {
Query query = db.collection("test-groups").document(groupid);
FirestoreRecyclerOptions<GroupResponse> response = new FirestoreRecyclerOptions.Builder<GroupResponse>()
.setQuery(query, GroupResponse.class)
.build();
}
Is there a way to add multiple queries to the FirestoreRecyclerOptions
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…