Receive notifications of newly pushed children

后端 未结 1 1517
日久生厌
日久生厌 2021-01-26 16:32

I\'m .push() ing into a firebase reference.

I want a listener to be able to come online, and then be notified only of newly .push() ed children

1条回答
  •  情歌与酒
    2021-01-26 16:42

    startAt() returns the oldest (first) records, where endAt() returs the last (newest) records, assuming you've used push() to store them.

    So this would give you the newest entries:

     ref.endAt().limit(1)
    

    Keep in mind that the first record you receive will be previously existing, so it should be discarded in the use case that only data added after a user comes online is of value.

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