How to only get new data without existing data from a Firebase?

后端 未结 4 946
无人及你
无人及你 2020-11-27 23:16

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

4条回答
  •  粉色の甜心
    2020-11-27 23:46

    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)
        })
      

提交回复
热议问题