Android Firebase multiple sort

我的梦境 提交于 2020-01-22 02:38:13

问题


I have a question about firebase sorting.

I have the next database:

{
    "-Ka8xxTgyFB8yYKH50j_addclose" : {
        "number" : 0,
        "point" : 949739,
        "timestamp" : 14824078463440,
        "username" : "Test 16062"
    },
    "-Ka8xzKecpbPr46Kx9gl" : {
        "number" : 0,
        "point" : 1480851,
        "timestamp" : 14842078463441,
        "username" : "Test 13599"
    }
}

I want to display data sorted by point. But i need rows only which created today.

If i filter the rows for timestamp:

return databaseReference
                .child("list")
                .orderByChild("timestamp")
                .endAt(end.getTime());

The endAt is work good. Only todays rows listed. But... Now i need to sort by point.

How can i do it?

There is any idea to change database or sort my list on clientside?

Thanks so much!


回答1:


You'll need to sort all your data client side as there can only be one orderBy column per query.

If you need to double sort server side you'll have to update your database to have a combined key that would hold both timestamp and point.



来源:https://stackoverflow.com/questions/41639877/android-firebase-multiple-sort

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!