0

I am trying to show the list of data based on the selected date, there is a list contain dates inside the child,how can i put the query of the selected date and compare it with the list of dates.

enter image description here

Query query = FirebaseDatabase.getInstance()
    .getReference()
    .child("PlanOfDoctor").orderByValue().equalTo(s.toString());

FirebaseRecyclerOptions<Plan> options =
     new FirebaseRecyclerOptions.Builder<Plan>()
         .setQuery(query, new SnapshotParser<Plan>() {
             @NonNull
             @Override
             public Plan parseSnapshot(@NonNull DataSnapshot snapshot) {
                 return new Plan(snapshot.child("name").getValue().toString(),
                     snapshot.child("hospital").getValue().toString(),
                     snapshot.child("location").getValue().toString());
                 }
             }).build();
Mohammed Hemaid
  • 115
  • 3
  • 10
  • add Firebase Realtime Database tag to your question. – Fire-In-D-Hole Mar 10 '19 at 13:23
  • Your current data structure allows you to efficiently get the dates for a given plan. It does not however allow you to efficiently read the plans for a given date. To allow that you'll need to create an inverse data structure, where you store the plans (or just their IDs) for each date. See my answer here for more on the why and how: https://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value – Frank van Puffelen Mar 10 '19 at 16:26
  • @FrankvanPuffelen thanks for the answer ! – Mohammed Hemaid Mar 10 '19 at 18:47

0 Answers0