MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
504 stars 58 forks source link

Uncaught (in promise): TypeError: _this._collectionRef.orderBy is not a function > GeoFirestoreQuery.prototype._listenForNewGeohashes #10

Closed wjrosa closed 6 years ago

wjrosa commented 6 years ago

Hi! I am trying to use the query like this: ... const geoFirestoreQuery = geoFirestore.query({ center: new firebase.firestore.GeoPoint(1, 2), radius: 10 }); Then I get this error:

Uncaught (in promise): TypeError: _this._collectionRef.orderBy is not a function GeoFirestoreQuery.prototype._listenForNewGeohashes/<@http://localhost:8100/build/vendor.js:101050:34 GeoFirestoreQuery.prototype._listenForNewGeohashes@http://localhost:8100/build/vendor.js:101046:9 GeoFirestoreQuery@http://localhost:8100/build/vendor.js:100721:9 GeoFirestore.prototype.query@http://localhost:8100/build/vendor.js:100640:16 GeoFirestoreProvider@http://localhost:8100/build/main.js:1450:34 _createClass@http://localhost:8100/build/vendor.js:10975:20 createProviderInstance$1@http://localhost:8100/build/vendor.js:10949:26 resolveNgModuleDep@http://localhost:8100/build/vendor.js:10934:17 NgModuleRef.prototype.get@http://localhost:8100/build/vendor.js:12159:16 resolveDep@http://localhost:8100/build/vendor.js:12655:12 createClass@http://localhost:8100/build/vendor.js:12525:32 createDirectiveInstance@http://localhost:8100/build/vendor.js:12364:37 createViewNodes@http://localhost:8100/build/vendor.js:13802:53 createRootView@http://localhost:8100/build/vendor.js:13692:5 callWithDebugContext@http://localhost:8100/build/vendor.js:15093:39 debugCreateRootView@http://localhost:8100/build/vendor.js:14394:12 ComponentFactory_.prototype.create@http://localhost:8100/build/vendor.js:11313:37 ComponentFactoryBoundToModule.prototype.create@http://localhost:8100/build/vendor.js:4275:16 NavControllerBase.prototype._viewInit@http://localhost:8100/build/vendor.js:50655:27 NavControllerBase.prototype._nextTrns/<@http://localhost:8100/build/vendor.js:50468:17 F</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14974 onInvoke@http://localhost:8100/build/vendor.js:4982:24 F</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14901 F</c</r.prototype.run@http://localhost:8100/build/polyfills.js:3:10124 f/<@http://localhost:8100/build/polyfills.js:3:20240 F</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15649 onInvokeTask@http://localhost:8100/build/vendor.js:4973:24 F</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15562 F</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10815 o@http://localhost:8100/build/polyfills.js:3:7887

Am I doing something wrong? I tried to use versions 1.2.0 and directly from the v2.0.0 branch. Thank you!

MichaelSolati commented 6 years ago

What version of Firebase are you using?

Like how are you instantiating the Geofirestore object?

Are you using AngularFire?

(Can you show more code)

Also, version 2 is not directly compatible with 1. There have been significant changes in how data is being returned (mind you those changes shouldn't have caused this error)

wjrosa commented 6 years ago

I am sorry. It was my mistake!

I was trying to use this: constructor(private db: AngularFirestore) { const geoFirestore = new GeoFirestore( this.db.collection('geofirestore') ); }

Instead of this (like you informed in the docs): const collectionRef = firebase.firestore().collection('geofirestore'); const geoFirestore = new GeoFirestore(collectionRef);

It looks like the output is different.

MichaelSolati commented 6 years ago

Yea, AngularFirestore returns a AngularFirestoreCollection type, you need a firebase CollectionRef try this...

constructor(private db: AngularFirestore) { const geoFirestore = new GeoFirestore( this.db.collection('geofirestore').ref ); }