I have a collection with "grup" name and have a subcollection named "anggota".
Please help me, how to display data by query referring to collection document and subcollection document.
Firestore collection:
I've tried with this query but it doesn't work, the data doesn't appear
db.collection("grup").document().collection("anggota")
.whereEqualTo("iduser", idUser)
.orderBy("updatetime", Query.Direction.DESCENDING)
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
List<DocumentSnapshot> list = value.getDocuments();
datalist.clear();
for (DocumentSnapshot d : list) {
final Modelfirestore c = d.toObject(Modelfirestore.class);
datalist.add(c);
}
mAdapterss.notifyDataSetChanged();
}
});
CodePudding user response:
When you are using the following query: