[英]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.