Question: I have a node in Firebase getting continually updated with information from a logfile. The node is `lines/` and each child of `lines/` is from a `post()` so it has a unique ID.

When a client first loads, I want to be able to grab the last `X` number of entries. I expect I'll do this with `once()`. From then on, however, I want to use an `on()` with `child_added` so that I get all new data. However, `child_added` gets *all* data stored in the Firebase and, after the initial setup, only want the new stuff.

I see that I can add a `limitToLast()` on the `on()`, but, if I say `limitToLast(1)` and a flood of entries come in, will my app still get all the new entries? Is there some other way to do this?

Answer: 
I think there is a problem in @David East's solution. He is using the local timestamp which may cause problem if the time is not accurate in client device. Here is my suggested solution (iOS Swift):

* Using `observeSingleEvent` to get the complete data set
* Then returned it in reversed order by `reversed()`
* Get the last timestamp by for example `data[0].timestamp`
* Using `queryStarting` for timestamp

```
 self._dbref.queryOrdered(byChild: "timestamp").queryStarting(atValue: timestamp+1)
     .observe(.childAdded, with: {
        snapshot in
        print(snapshot.value)
  })

```
Here's temporary but quick solution:

```
// define a boolean
var bool = false;

// fetch the last child nodes from firebase database
ref.limitToLast(1).on("child_added", function(snap) {
    if (bool) {
        // all the existing child nodes are restricted to enter this area
        doSomething(snap.val())
    } else {
        // set the boolean true to doSomething with newly added child nodes
        bool = true;
    }
});

```

**Disadvantage:** It will load all the child nodes.

**Advantage:** It will not process existing child nodes but just the newly added child nodes.

`limitToLast(1)` will do the work.