Closed delphiy closed 5 years ago
Could you share some code example as well as the output?
Hi, I know where is the problem but not solution.
The problem that in firestore database , the collection cities(for example) . I saved only position as geopoint because it came from andriod and ios . I do not saved g and l fields.
I only have position which contain geopoint in database so no hash value.
no solution for this
So documents that can be queried by geofirestore must be added by geofirestore. What you could do is set up a Firestore trigger that will automatically convert your document. (it may look like below)
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import { GeoFirestore } from 'geofirestore';
export const geoOnCreate = functions.firestore.document('collection/{key}').onCreate((snapshot) => {
const geofirestore = new GeoFirestore(admin.firestore());
const collection = geofirestore.collection('collection');
const documentReference = collection.doc(snapshot.id);
const document = snapshot.data();
// You may need to assign a GeoPoint to the coordinates field of your document
// or you can tell geofirestore what field to look for the GeoPoint
document['coordinates'] = new admin.firestore.GeoPoint(0,0);
return documentReference.set(document, /** You can set the field to use for the coordinates here, if it isn't 'coordinates' */);
});
We don't have an ios/android library yet, but we're looking into android next (and would love someone to step up for ios!) You could also use cloud functions to insert documents with geofirestore (but how you do that is up to you);
The result is empty Typescript cloud function