Firebase limitToLast查询 [英] Firebase limitToLast Query

查看:113
本文介绍了Firebase limitToLast查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题可能很愚蠢,我已经阅读了文档,但还没有解决我的问题的方法.当我使用limitToLast获取最后15条消息时(例如从5-20开始),如果我删除了20条消息,则childListener会向我返回这样的消息(5-6-7-8-9-10-11-12- 13-14-15-16-17-18-19-4)...如您所见,最后一项是数字4. 代码如下:
messagesListener = FBMessagesRef.limitToLast(15).addChildEventListener(new ChildEventListener(),我该如何解决却没有得到第四项

My question maybe a silly one, I´ve read the documentation but haven´t got a solution to my question. When I use limitToLast to get the last 15 messages (lets say from 5-20) and if I delete the 20th message, the childListener returns me messages like this (5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-4)... As you can see the last item is number 4. The code is like so:
messagesListener = FBMessagesRef.limitToLast(15).addChildEventListener(new ChildEventListener(), how can I fix it and dont get the 4th item

推荐答案

由于将值设置为15时将获得最后15位数字,因此将limitToLast值更改为-1即可获得最新的Firebase值. 将您的代码更改为以下代码段.

Since you're getting the last 15 digits when you set the value to 15, change the limitToLast value to -1 to get the last Firebase value. Change your code to below snippet.

messagesListener = FBMessagesRef.limitToLast(-1).addChildEventListener(new ChildEventListener(),

这篇关于Firebase limitToLast查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆