MichaelSolati / geofirestore-js

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

orderBy inside inner query doesn't work #41

Closed iamswain25 closed 6 years ago

iamswain25 commented 6 years ago

this one works const query = ref => ref.limit(4) const geoQuery = geofirestore.query({ center, radius, query })

this one doesn't const query = ref => ref.orderBy('d.createdAt', 'desc') const geoQuery = geofirestore.query({ center, radius, query })

nothing comes through key_entered event listener I set the indexing on firestore as it advises me to: d.createdAt DESC g ASC

MichaelSolati commented 6 years ago

So ref.limit will not really work all the time... It's a side effect of how the service works, you can see an explanation here.

Anyway, I did some digging and testing, and here are a few issues regarding Firestore queries and GeoFirestore (and the docs should and will be updated to reflect this).

  1. You can not use startAt or similar modifiers (startAfter, endBefore, endAt) with GeoFirestore since we append the geo based modifiers to the end of a query and you cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().
  2. It looks like while Firestore could support two orderBys, it can not support two orderBys AND two of the previously mentioned modifiers (startAt, startAfter, endBefore, endAt). It seems as if it has been somewhat documented as an issue here by a member of the Firebase team.

I'll be updating the docs to reflect this.