有没有办法从某个索引获取firebase元素?

编程入门 行业动态 更新时间:2024-10-28 21:17:26
本文介绍了有没有办法从某个索引获取firebase元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个按时间戳排序的聊天消息列表,并且具有唯一的Firebase密钥(由推送操作员创建)

I have a list of chat messages that are ordered by timestamp and have a unique firebase key (made by the push operator)

在此列表中,我想从末尾获得消息,位置为100,但不知道其密钥. 有办法吗?

In this list I want to get the message at position 100 from the end without knowing its key. Is there a way to do this?

我尝试同时使用限制方法limitToLast()和limitToFirst,这创建了一个错误,说明已经设置了过滤器.

I tried using the filtering methods limitToLast() and limitToFirst together which created an error, saying a filter was already set.

我当前的操作方式是使用以下命令下载所有100条消息:

The current way I do it is by downloading all 100 messages with:

admin.database().ref("path/to/messages").limitToLast(100)

然后我在列表中查找我想要的第一把钥匙.

And then I look into that list for the first key which is the one I want.

还有一种方法可以获取第100条消息而不下载其他所有消息吗?

Is ther a way that I can get the 100th message without downloading all the other messages as well?

推荐答案

Firebase Realtime数据库查询不支持指定偏移量,而是要求您知道锚点文档的键值.如果您不了解这些内容,则必须在搜索文档之前/之后阅读所有文档.

Firebase Realtime Database queries don't support specifying an offset, but instead require that you know the key values of the anchor document. If you don't know those, you will have to read all documents before/after the one you search for.

另请参阅:

  • 如何在recyclerview中动态更改limitToFirst()火力基地?
  • AngularJS:从Firebase提取分页记录
  • 如何读取Firebase数据库
  • Firebase分页数据.有可能吗?
  • How to change limitToFirst() dynamically in recyclerview firebase?
  • AngularJS : Fetch records for pagination from Firebase
  • how to read firebase database
  • Firebase paging data. Is it possible?

更多推荐

有没有办法从某个索引获取firebase元素?

本文发布于:2023-11-28 19:18:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   索引   元素   firebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!