Closed tzvc closed 3 years ago
Instead of an await, try doing a traditional promise and apply the catch. I'd love to see what if any error appears.
@MichaelSolati With a traditional then/catch, I dont get any errors, but no results (where they should have been)
const geocollection = GeoFirestore.collection('posts', 'location');
const geoQuery = geocollection
.near({
center: new admin.firestore.GeoPoint(query.centerLat, query.centerLng),
radius: query.radius,
})
.where('community', '==', req.params.community)
.limit(10);
return geoQuery
.get()
.then(v => res.status(200).json(v.docs))
.catch(e => console.error(e));
I believe this issue was documented here too: https://github.com/MichaelSolati/geofirestore-js/issues/199
Also, by looking at the source of geofirestore-core, it doesn't appear to support custom keys as it uses the g
key statically https://github.com/MichaelSolati/geofirestore-core/blob/main/src/api/query-get.ts#L83
What version are you using and can you show me what a document in Firestore looks like?
The custom key shouldn't matter on query as its used to encode into the .g
field.
@MichaelSolati I'm using 4.4.2
and my documents looks like this
{
location: {
geopoint: GeoPoint,
geohash: string
},
// other fields...
}
Ok, so the geopoint that you use in your doc can be any field, but you are right that geofirestore uses the g
property.
Are you manually creating that location
property?
@MichaelSolati The location
property is created in the flutter frontend via https://pub.dev/packages/geoflutterfire, which allows a field name to be specified (which is porb. why I assume this worked the same way)
Got it, unfortunately no, this library doesn't support custom property names for queries, only to encode the document.
It's a good feature for down the road but not something I see myself getting to any time soon.
Fair. If I end up implementing it, I'll make sure to submit a PR ;)
In any case, thank you for your time!
firebase
,firebase-admin
, etc...) and version: firebase-adminHi there, I'm trying to use a custom key for my geoqueries instead of the default
g
but I'm running into some issues.When I specify a customKey in the
GeoFirestore.collection
, then create a query from that and run it, the query is run ong.geohash
instead of the specified customKeylocation.geohash
.Upon reading the source code, it appear to me that the customKey is only used when adding new documents.
Am I missing something here ?
Cheers!