vihkat
vihkat

Reputation: 1005

Android Firebase multiple sort

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!

Upvotes: 0

Views: 3099

Answers (1)

Mathew Berg
Mathew Berg

Reputation: 28750

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.

Upvotes: 3

Related Questions