Firebase observe with type .childAdded retrieves all my information every time. Please assist

后端 未结 1 1214
日久生厌
日久生厌 2020-12-16 06:38

According to Firebase docs:

ChildAdded is triggered once for each existing child and then again every time a new child is added to the specified path

1条回答
  •  情歌与酒
    2020-12-16 07:30

    A few ways to do this:

    • Use ref.queryLimitedToLast(1) when you start. See Firebase, only get new children.
    • keep track of the most recent key you've got in your local storage and then query with queryOrderByKey().queryStartingAtValue(latestKey)
    • Add a timestamp to the items and then queryOrderByChild("timestamp").queryStartingAt(now) for items with timestamp >= now. See how to discard initial data in a Firebase DB

    0 讨论(0)
提交回复
热议问题