Firebase Querying Data Up And Down From The Middle Key
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 da
Solution 1:
I have changed the way keys are defined.
Instead of push()
, I have set the key with the combination of date and push().
Like, the new key is in the following format YYYYMMDD<PUSH_KEY>
. With this format, I am able to query data with 2 separate queries.
One ending with the key:
ref.orderByKey().endAt(key).limitToLast(1)
and one starting with the key:
ref.orderByKey().startAt(key)
This gives me the results from both the ends from the middle key.
Thank you @puf and everyone for the comments and help.
Post a Comment for "Firebase Querying Data Up And Down From The Middle Key"