I've a list of documents which looks like below structure.
Posts ->
->uuid_1
-> approvedCount : 5
-> postMsg : "Hello world 1"
-> Timestamp : 1234567890
-> userId : "user1"
->uuid_2
-> approvedCount : 6
-> postMsg : "Hello world 2"
-> Timestamp : 1234567891
-> userId : "user2"
There may be thousands of the posts in firestore and the size is ever increasing.
condition -> approvedCount
must be greater then 5 when filtering in query.
Now I want to fetch 20 records every day in ascending order of the timestamp. I don't want to get duplicate so lets say today I fetched 20 first records in ascending order now tomorrow I want to fetch next 20 and so on..
I tried something like
FirebaseUtil.getFireStoreDB("Posts").whereGreaterThan("approvedCount", 5)
.limit(20)
.orderBy("Timestamp", Query.Direction.ASCENDING)
.get()
But don't get the idea how I'll fetch next posts everyday. Because from the docs I got to know you can't query 2 fields with < or > otherwise it will be easier with timestamp and approvedCount