Closed Carvalho96v2 closed 5 years ago
Hi @Carvalho96v2, You could make a copy of geopoint in the outer model as an alternative. But, I'm just trying to understand what's the purpose of making it flat, they both are coupled together as a class in the library. Unless there's a specific advantage in making them flat, I don't think it's a necessity for the library!
Hey @DarshanGowda0 , the reason why I'd like a flat model is (correct me if I'm wrong), Firestore does not yet support collection group queries, meaning that I can only query a subcollection if I know which parent collection to query in the first place.
This stackoverflow question explains the use case pretty well.
Do let me know if there is a better workaround that I'm missing :)
Edit: A better representation of my data model using geoflutterfire as is:
User [collection]:
@Carvalho96v2 Yes that's true, but this implementation still doesn't store geopoint/geohash in a subcollection! It's in the same collection stored as a nested object. I think you're confusing nested objects inside firestore documents and subcollections.
Examples of how the document is structured
Another one where you can store the geoflutterpoint inside a nested object
As you can see, the position
field in the document is not a subcollection as you think, it's an object in the same document.
@DarshanGowda0 Whoops, my bad. Thanks for clearing that up! I'll close this issue now :)
Its a great library by the way <3
Thanks, @Carvalho96v2 😄
Currently, within() only takes one possible field as the "position" field, however in my use case I have a flat data model (i.e, geohash and geopoint fields are not in their own collection, but are fields within my main collection).
Thus, my data model looks as follows: User:
As opposed to: User:
Thus, there are 2 separate fields that represent the "position"
I've hacked together my own solution by creating "flat_within" and "_flat_querypoint" methods, which I'll be happy to share and which works for now, but obviously will become an issue as this library grows.
I hope this has been clear :)