michaelsolati / geofirestore-core Goto Github PK
View Code? Open in Web Editor NEWLightweight location-based querying and encoding of Firebase Firestore Documents for geofirestore.
Home Page: https://core.geofirestore.com
License: MIT License
Lightweight location-based querying and encoding of Firebase Firestore Documents for geofirestore.
Home Page: https://core.geofirestore.com
License: MIT License
This looks like a great package, many thanks! ๐
I'm currently setting it up and ran into two issues:
Are you mutating the object passed to geocollection.add
? I'm guessing so, as you are adding the g
key. Can this not be done without mutation, as it is a wrapper I presume? Because I'm getting unexpected behavior with the object i'm passing, namely the sudden appearance of the g
key.
I didn't see the firestore.rules
file at first. As the README only mentioned the following:
interface GeoDocumentData {
g: {
geohash: string;
geopoint: GeoPoint;
};
[field: string]: any;
}
I adjusted my security rules accordingly, assuming the coordinates
would be stripped (it's duplicate data). Is this field used for anything? If not, can this not be removed at the same time that g
is added? Would be very helpful if the README was more clear about the necessary changes to the security rules.
firebase
, firebase-admin
, etc...) and version: firebase: 8.0.2, firebase-admin: 9.4.1geofirestore-core
version: 4.1.2geofirestore
version: 4.3.0See error below:
โฏ ./node_modules/.bin/tsc --watch
[4:08:38 PM] Starting compilation in watch mode...
node_modules/geofirestore-core/dist/definitions.d.ts:2:10 - error TS2614: Module '"../../firebase"' has no exported member 'firestore'. Did you mean to use 'import firestore from "../../firebase"' instead?
2 import { firestore as webfirestore } from 'firebase/app';
~~~~~~~~~
[4:08:43 PM] Found 1 error. Watching for file changes.
import * as geofirestore from "geofirestore";
Currently the method generateGeoQueryDocumentSnapshot()
returns a QueryDocumentSnapshot.
This only exposes a few methods or properties compared to a Firebase QueryDocumentSnapshot.
This means that what one can expect from either a generic Query or a GeoQuery is very different,
making passing results to generic functions a bit non unified (talking about geofirestore-js here).
With version v2.2.3 of geofirestore-js I had patched (but not PR'ed) theQueryDocumentSnapshot
.
So it would expose QueryDocumentSnapshot
methods, making it a drop-in replacement/addition.
As a sketch/conversation starter I did the same thing for the 5.0.0 version of geofirestore-core
This means that the implementing geofirestore-js would start to return the missing methods.
Now I say as a sketch, because I struggle with TypeScipt ( hence :any ),
and there are probably some semantics or reasons to take into account.
The commit does a few things.
Types
GeoFirestoreTypes.QueryDocumentSnapshot
to GeoFirestoreTypes.QueryDocumentSnapshotData
, as the type was more ...Data
than ...Snapshot
decodeGeoQueryDocumentSnapshotData()
, type QueryDocumentSnapshotData
is still semantically valid and usedGeoFirestoreTypes.QueryDocumentSnapshot
is updated to extend the Firebase.QueryDocumentSnapshot
type, (exposing all methods) and adding distance : number
Methods
generateGeoQueryDocumentSnapshot()
now returns the original snapshot methods, and properties, but overwriting data()
with decoded.data()
and adding {distance : decoded.distance}
I wonder if this would be a good addition or if there are reasons why (not) to return the original snapshots.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.