Query Firestore Against A List Of Documents
I have a List of names referring to Documents that I want to retrieve from FireStore. I want to access the contents after they are finished loading so I have implemen
Solution 1:
According to your comment:
I have a List of Document names and I need to transform this to essentially a List of Tasks to retrieve the entire document.
To solve this, please use the following lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference collRef = rootRef.collection("yourCollection");
List<String> myGroupTags = newArrayList<>();
List<DocumentReference> listDocRef = newArrayList<>();
for(String s : myGroupTags) {
DocumentReference docRef = collRef.document(s);
listDocRef.add(docRef);
}
List<Task<DocumentSnapshot>> tasks = newArrayList<>();
for (DocumentReference documentReference : listDocRef) {
Task<DocumentSnapshot> documentSnapshotTask = documentReference.get();
tasks.add(documentSnapshotTask);
}
Tasks.whenAllSuccess(tasks).addOnSuccessListener(newOnSuccessListener<List<Object>>() {
@OverridepublicvoidonSuccess(List<Object> list) {
//Do what you need to do with your listfor (Objectobject : list) {
GroupBase gb = ((DocumentSnapshot) object).toObject(GroupBase.class);
Log.d("TAG", tp.getPropertyname);
}
}
});
Post a Comment for "Query Firestore Against A List Of Documents"