I have a list of data having date. I usually query that data sorted by date. But I am in a situation when I need to retrieve some data back and forth from the middle key. I have data sorted by date (orderByChild("date")
) like this:
{
"key1":{
"date": "2016-07-25"
},
"key2":{
"date": "2016-07-26"
},
"key3":{
"date": "2016-07-27"
},
"key4":{
"date": "2016-07-28"
},
"key5":{
"date": "2016-07-29"
}
}
Note: Dates can be in future also. There can be multiple entries for each date. There can be a gap between two dates.
If I know the key3
, How can I retrieve data from one above key3
(i.e. key2
) to end of the list (i.e. key5
)?
So for example,
- with key3 -> key2 to key5 (till end).
- with key4 -> key3 to key5 (till end).
How can I query it with key, and order by child "date". I have a key2. And from that I need to fetch the list.
I have tried to fetch results in parts, by one for upper and one for lower. But, when I use orderByChild("date")
, I can not use endAt()
with keys (Docs says: you can combine the startAt()
and endAt()
methods to limit the results to a specified range of values).
Is there any way I can retrieve the list based on key? In a single go or in parts?