android - Firebase querying data up and down from the middle key -


i have list of data having date. query data sorted date. in situation when need retrieve data , forth middle key. have data sorted date (orderbychild("date")) 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 in future also. there can multiple entries each date. there can gap between 2 dates.

if know key3, how can retrieve data 1 above key3 (i.e. key2) end of list (i.e. key5)?

so example,

  • with key3 -> key2 key5 (till end).
  • with key4 -> key3 key5 (till end).

how can query key, , order child "date". have key2. , need fetch list.

i have tried fetch results in parts, 1 upper , 1 lower. but, when use orderbychild("date"), can not use endat() keys (docs says: can combine startat() , endat() methods limit results specified range of values).

is there way can retrieve list based on key? in single go or in parts?

i have changed way keys defined.

instead of push(), have set key combination of date , push().

like, new key in following format yyyymmdd<push_key>. format, able query data 2 separate queries.

one ending key:

ref.orderbykey().endat(key).limittolast(1) 

and 1 starting key:

ref.orderbykey().startat(key) 

this gives me results both ends middle key.

thank @puf , comments , help.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -