Reputation: 59
I'm trying to retrieve data from a Firebase sub collection in a recyclerview. I think it must be possible but what I did was not right I think
I want to recover the data from REPARS_TABLE in Recyclerview Android - Cloud Firestore
Query query = db.collection("RESTO_TABLE").document().collection("REPARS_TABLE").orderBy("nomRepars");
FirestoreRecyclerOptions<ReparsModele> OptionRepars = new FirestoreRecyclerOptions.Builder<ReparsModele>()
.setQuery(query,ReparsModele.class)
.build();
Log.d("SHOW","SHOW QUERY"+ query);
bureauReparsAdapter = new BureauReparsAdapter(OptionRepars);
repaLists.setHasFixedSize(true);
repaLists.setLayoutManager(new LinearLayoutManager(getContext()));
repaLists.setAdapter(bureauReparsAdapter);
bureauReparsAdapter.notifyDataSetChanged();
Upvotes: 0
Views: 93
Reputation: 317362
You will need to call out the ID of the document whose subcollection you want to you. Right now, you're calling document()
with no parameters, which means it's generating a random ID as part of the path. You will need to instead pass it the ID of the document.
If you don't know the ID ahead of time, then you won't be able to do this query, or you will have to use a collection group query and filter the documents you want from all of the subcollections named "REPARS_TABLE".
Upvotes: 1