Reputation: 37
When we call. childAdded function initially it fetches all the records from the given link. And then after that it fetches the only newly added record. Is there any way to prevent fetching all the data from Firebase initially. I want to show a popup whenever a new record is added in Firebase and i want to fetch only the latest record but .childAdded first fetches all the data in Firebase.
Upvotes: 0
Views: 143
Reputation: 317487
It's not possible unless you put a timestamp value in each record. If you have a timestamp, then you can query for only the children that have a timestamp greater than the current time. Typically one uses ServerValue.timestamp() as the value of a child to automatically get the server's sense of time into that field.
Upvotes: 1