My structure:
privateChatsDetails
{
pushKey1{
lastMessage
{
displayName(String)
photoUrl(String)
text(String)
time(Long value)
uid(String)
}
users
{
user1Uid
{
chat = true
some other details..
}
user2Uid
{
chat = true
some other details..
}
}
pushKey2
lastMessage{...}
users{...}
....
}
I'm reading all chats into Listview using
mFirebaseDatabaseReference.child("privateChatsDetails").orderByChild("users/" + mUid + "/chat").equalTo(true)
Working perfect, but not ordered well, I'm trying to order by lastMessage/time,
After reading the Index Your Data docs, and some Stackoverflow questions, I tried some rules, no succeeded.
What I have already tried:
"rules": {
"$privateChatsDetails": {
"lastMessage": {
".indexOn": ["time"]
}
}
}
And:
"rules": {
"privateChatsDetails": {
".indexOn": ["lastMessage/time"]
}
}
And:
"rules": {
"privateChatsDetails":{
"$lastMessageTime": {
".indexOn": ["lastMessage/time"]
}
}
}
Any idea? Thanks in advance.