简体   繁体   English

Firebase分页下载全库

[英]Firebase Pagination download whole database

I am using firebase pagination to limit the firebase database downloads but the firebase console still shows lots of database downloads,我正在使用 firebase 分页来限制 firebase 数据库下载,但 firebase 控制台仍然显示大量数据库下载,

DatabaseReference db = FirebaseDatabase.getInstance().getReference().child("Posts").child(country).child(phase);

query = db.orderByChild("random_no").startAt(min).limitToFirst(limit);

FirebaseRecyclerOptions<Photo> options =
                new FirebaseRecyclerOptions.Builder<Photo>()
                        .setQuery(query, Photo.class)
                        .build();

I hope it downloads the whole database before pagination.我希望它在分页之前下载整个数据库。

Can anyone help how to do firebase pagination without downloading whole database.任何人都可以帮助如何在不下载整个数据库的情况下进行 firebase 分页。

If you tell the Firebase data to order/filter its results, it will always do so.如果您告诉 Firebase 数据对其结果进行排序/过滤,它将始终这样做。 It can only do this on the server however, if you've defined the necessary index in the rules of your database.但是,如果您在数据库规则中定义了必要的索引,它只能在服务器上执行此操作。 If no such index is found, the SDK will download all the nodes at the path, and order/filter them in the application itself.如果没有找到这样的索引,SDK 将下载路径中的所有节点,并在应用程序本身中对它们进行排序/过滤。 If this happens, it will also log a warning with instructions on what index to add to your logcat output.如果发生这种情况,它还会记录一条警告,其中包含有关将什么索引添加到您的 logcat output 的说明。

So most likely you didn't define an index on random_no for /Posts/$country/$phase in your database rules.所以很可能你没有在你的数据库规则中为/Posts/$country/$phase定义random_no的索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何删除 firebase 数据库中的整个关键数据? - How to delete whole key data in firebase database? 如何限制 Firebase 实时数据库的结果显示最新的分页? - How to limit the results of Firebase Realtime Database to show most recent for pagination? Firebase 实时数据库下载使用率高 - Firebase realtime database high download usage Firebase:如何一次只获取 n 条记录而不是整条记录 firebase 实时数据库? - Firebase: How to get only n records at a time instead of whole record firebase real time database? Firebase 分页过滤器 - Firebase filter with pagination Firebase 实时数据库 equal_to() 方法获取整个文档而不是仅获取父文档 - Firebase Realtime Database equal_to() method gets the whole document instead of the parent only Firebase onSnapshot限制下载 - Firebase onSnapshot limit download 云中的多个连接和巨大的下载开销 function 由写入 firebase 实时数据库触发 - multiple connections and huge download overhead in cloud function trigged by writes in firebase realtime database 下载托管在 Firebase 中的图像 - Download an image hosted in Firebase Firebase 分页使用时间戳/日期作为 orderBy - Firebase pagination using a timestamp/date as the orderBy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM