Home > database >  How to get Firebase realtime database list items based on date
How to get Firebase realtime database list items based on date

Time:10-17

I am trying to get list of data from firebase realtime database in a Flutter project and apply a where condition to it. database structure structure of the data

and I would like to filter the list based on the date shown in the image. I am using flutter_database package.

DatabaseReference ref = FirebaseDatabase.instance.ref("activities/${widget.project.id}");

I wonder how to apply the "where" condition?

CodePudding user response:

You can use date field in the orderByChild and set the date in startAt

ref = FirebaseDatabase.instance.ref("activities").child('${widget.project.id}')
                      .orderByChild('date').startAt("2022-10-16 00:00:00.000");
print("------------------");
ref.once().then((value)  {
  print(value.snapshot.value);
  print("");
});
  • Related