MichaelSolati / geofirestore-js

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

Issue with Query when 'where' is used #142

Closed LureOfAdventure closed 5 years ago

LureOfAdventure commented 5 years ago

Hey, thanks for an awesome library! I'm using Firebase Functions and testing it out the query on one of my Firestore triggers. it works great when I'm doing a simple 'near' query but as soon as I add a 'where' it returns 0. Below is a screenshot of my db and code. Any advice would be helpful.

Screen Shot 2019-10-05 at 2 32 22 PM Screen Shot 2019-10-05 at 2 31 43 PM
MichaelSolati commented 5 years ago

Have you indexed your database? The query may be failing because it's not queried... Once you execute get() on the query you should do a catch to see if it gives you a url to index your database.

If you're doing an onSnapshot instead of get the second callback would be your error handler.

LureOfAdventure commented 5 years ago

@MichaelSolati Yeah my db is index. I am doing a get. I've attached more screenshots that can clarify things. I'm not getting back any errors either. Thank you for your prompt response!

Screen Shot 2019-10-05 at 8 42 14 PM Screen Shot 2019-10-05 at 8 42 00 PM
MichaelSolati commented 5 years ago

Ok, so I missed something obvious when looking over your screenshots (my bad). Data queried by geofirestore needs to be maintained by geofirestore, and geofirestore stores all data associated with your object inside the d property, not at the top level. It's an inconvenience, but a necessity at this time.

I do plan on changing how geofirestore works, but time constraints have prevented me from working on v4.0.0.

LureOfAdventure commented 5 years ago

Ah okay gotcha! Any chance you might know when v4.0.0 will be out? :)

mattwebhub commented 5 years ago

@MarkedWarrior Did you make this work?

LureOfAdventure commented 5 years ago

@barakoles yeah I just restructured my data to be included under d and everything worked correctly

mattwebhub commented 5 years ago

@MarkedWarrior Awesome, you used the same query and had to index the db as well right? BTW, what is this 'formater' you use that highlights the parameters you should use? thanks dude

LureOfAdventure commented 5 years ago

@barakoles Yep, same query! Oh I use Webstorm with typescript installed

NickCarducci commented 4 years ago

I have been itching to figure this out and I guess this issue is good place as any to note this for geofirestore users:

firebase.initializeApp(firebaseConfig).firestore()
  .collection("planner")
  .where("d.authorId", "in", [`${this.props.auth.uid}`])