The title might imply this is nonsensical, but I’m trying to limit the amount of data retrieved from Firebase. I have a query structured like this:
for (final Map.Entry<String, String> entry : map.entrySet())
{
final Query dataQuery = mFirebaseRef.child("someChild").child(entry.getKey());
dataQuery.addListenerForSingleValueEvent(new ValueEventListener()
{
// do something with data
}
}
Each child returned has a timestamp
. Now I want to limit the query further by only returning children in the Map that have timestamp newer than the previous query.
If I form a query such as this:
final Query dataQuery = mFirebaseRef.child("someChild").orderByChild("timestamp").startAt(timeMsec);
Then it works and the query returns all children meeting that criteria.
But I want to first limit only to children in the Map (using .child(entry.getKey()
), and then check the timestamp
values that meet that criteria. i.e.
for (final Map.Entry<String, String> entry : map.entrySet())
{
final Query dataQuery = mFirebaseRef.child("someChild").child(entry.getKey()).orderByChild("timestamp").startAt(timeMsec);
...
And this doesn’t work even when children have a timestamp
that meet the criteria. Is this a specific limitation that orderByChild
doesn’t work when the query returns a single child? A simple check is to use timeMsec = 0
and nothing is returned by the query.