MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

Query documents within a day #146

Closed mattwebhub closed 5 years ago

mattwebhub commented 5 years ago

EDIT I read through the post and found that such queries cannot be made. Is there a timeline for this problem to be solved tho? This is a big requirement for an app so I'd probably have to use another solution if such filtering can't be made. Hi all, thanks for this awesome lib. I'm having a hard time figuring out how to use the .where() parameter with geofirestore. It works if I use == but it does not with inequality operators I have indexed my collection with a d.createdAt - g but when I use a < operator it throws me this error:

FirebaseError: Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field 'd.createdAt' and so you must also use 'd.createdAt' as your first Query.orderBy(), but your first Query.orderBy() is on field 'g' instead.

bellow my query code

    let query = await geocollection.limit(50).near({
      center: new firebase.firestore.GeoPoint(
        location.coords.latitude,
        location.coords.longitude
      ),
      radius: radius
    }).where('createdAt','<','31413')
MichaelSolati commented 5 years ago

This problem can never be solved by geofirestore based on limitations of Firestore and geohash queries. Firestore doesn't allow for compound range queries => https://firebase.google.com/docs/firestore/query-data/queries#compound_queries