-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: add fieldname to near function #193
Comments
@SchnMar could you share a very simple example of what you mean? Or an example of the data structure created by the flutter library you're using? |
@MichaelSolati Sure, thank you for your quick reply. I have a collection called "user", which contains a field location, which contains location data created by my flutter app. Now, I want to query all users within a given area using GeoFirestore. I need to do this in a cloud function as I want to send a push notification to users within an area. As mentioned geoflutterfire has a within-function for these cases, which includes a fieldname parameter. Maybe that's a solution in JavaScript as well? (https://pub.dev/packages/geoflutterfire) Thank you, |
Any news on this? Would love to hear back from you @MichaelSolati. |
@MichaelSolati I'm also wondering for the same reasons but to use your library server-side. The core need is to flexibly make a query based on geolocation data nested under a property/field of the document. This is done by GeoFireX as seen here. With this improvement, you could have many GeoPoints and their geohashes per document to store and query by, which is actually a reason I went to use GeoFireX for a project instead of this library because you can't flexibly store more than a single field named "coordinates" with GeoFirestore. The current issue with GeoFireX is that you can't use it with Firebase >8.0.0. If you could add this to GeoFirestore it would bring in all the unhappy developers who tried using GeoFireX but couldn't. |
Have you looked at the GeoCollectionReference:constructor(), where a Not sure if it will work in a nested way, but the dot notation of nested field names (as a string) is supported in firebase e.g ( import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';
import * as geofirestore from 'geofirestore';
firebase.initializeApp({
// ...
});
const firestore = firebase.firestore();
const GeoFirestore = geofirestore.initializeApp(firestore);
const geocollection = GeoFirestore.collection('users', 'location.position'); // Dot notation as string
const query = geocollection.near({ center: new firebase.firestore.GeoPoint(40.7589, -73.9851), radius: 1000 });
query.get().then((value) => {
console.log(value.docs);
}); Of course if that doesn't work then your request would be a nice to have, but it think it is simple(r) to catch it on the implementation side. By creating a serverside trigger (or implement it client side), where the nested location data is also written to a under_scored_field on the top level e.g : "users" : {
[{uid}]:{
[..]
"location" : {
[..]
"position" : {[2]}
}
// Start duplicated data
"location_position" : {
"geohash": string;
"geopoint": GeoPoint;
}
} |
@spoxies I was under the impression this was to be able to index a document with many fields. So like, a user can have a home location and a work location, and you could query either one. Though you are right, you can set the property you want to index in the constructor of a GeoCollection and index that field. |
Hello Michael,
first of all, thank you for this amazing package. I'm trying to use it in a cloud function for my flutter app. To be able to use it, I need an extension of the near function.
In my flutter geofire I use a "within"-function, which has 3 parameters:
The third optional parameter is what I need. In this parameter, I can pass a field name for a given field structure within my document. This structure contains the location data required by Geofire.
Can you extend the library or is there already a possibility within the given library for this functionality?
Best,
Marcel
The text was updated successfully, but these errors were encountered: