We are building a app where we need to show nearby posts, made by users. A post should only be shown, if it is not more as 4 hours since posting. Because firestore doesn't provide geoquerys, i have to do a search, where all posts in a specific square are returned. This is my current query:
collection("posts")
.where("creation", isGreaterThan: DateTime.now().subtract(Duration(hours: 4)))
.where("location", isLessThan: cornor1OfSquare)
.where("location", isGreaterThan: cornor2OfSquare)
The problem with this query is, that it's not allowed to add multiple where statements filtering on different fields.
Filtering by one property locally and one on the server side is not possbile, because we have millions of posts in our app.
Is there any other way to do this? For example restructure the data on the server, to make queries like this possible? I researched, but only found solutions, with "simple" data. But i have a Timestamp and a GeoPoint field, which makes it more complex.
The second approach, which comes to my mind, is to use cloud functions, but i have no idea how to do that, and if it is the best solution available.
I am programming in Dart/Flutter.