First of all, I am coding in Kotlin.
I'd like to arrange the posts stored in the Realtime Database for a certain period of time based on the number of likes and display them in the RecyclerView.
my database structure
"posts": {
"key": {
"uid": "NHYVkW...",
"title" : "Title",
"time": "1666852764028",
"like" : 2
}
I've read about methods orderByChild()
, startAt()
, and endAt()
, but I don't know how to use them in combination.
The examples I've seen set startAt()
and endAt()
for the key that enters orderByChild()
.
But I want the sort to be based on like and the start and end points based on time.
Any examples I can refer to? Please help.