【发布时间】:2016-03-13 10:31:27
【问题描述】:
我将数据存储在 Firebase 存储中。
对象Comment 具有timestamp 属性。当我将数据从设备推送到 Firebase 时,我使用 currentTime 填充 timestamp 并存储在 long 数据类型中。
当我使用firebaseRef.orderByChild("timestamp").limitToLast(15) 检索数据时,结果没有按照我的预期排序。
我什至玩弄规则却没有结果:
{
"rules": {
".read": true,
".write": true,
".indexOn": "streetrate",
"streetrate": {
".indexOn": ".value"
}
}
}
我尝试将timestamp 存储在String 数据类型中,同样的问题。
【问题讨论】:
-
我建议按您想要的值排序,然后向后翻页。 (按 asc 排序,然后从末尾减去 x 个条目进行翻页。)
标签: android firebase sorting firebase-realtime-database