I use firestore in a flutter application. I have a collection of post. Each post have a number of like, and a creation date. I would like get the most liked posts in the last week, last day, last month... So i have to do a isGreaterThanOrEqualTo on the time and sort by like. But this is impossible, because i can't sort on two field. Actualy to resolve this problem i have add in my post document 3 field : "month" (month number), "week" (week number), "day" (day number).
And my query is like :
Query query = firestore.collection("post");
query = query.where("month", isEqual: 3);
query = query.orderBy("like", descending: true);
QuerySnapshot data = await queryResult.getDocuments();
It works very well. But I would like the most liked posts of the last 30 days, not really a specific month. And I don't know if it's possible to do that with firestore. Get all the documents and sorting afterwards is not a suitable solution for me.
Is there a solution to this problem?