MichaelSolati / geofirestore-js

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

Cannot initiate GeoFirestore instance in node.js application #58

Closed ghost closed 5 years ago

ghost commented 5 years ago

I use GeoFirestore in my node.js application. In the first lines of the document i have: var GeoFirestore = require("geofirestore");

And then i use the code const geoFirestore = new GeoFirestore(collectionRef); With the collectionRef being a valid ref to the my firestore collection.

The issue is that i get the error "TypeError: GeoFirestore is not a constructor" What is the problem here? Thanks for any help.

MichaelSolati commented 5 years ago

The index.js of geofirestore exports a few different files, so I can say your import wouldn't work. I believe you would want to do this (if you're not using Typescript or an ES6+):

var GeoFirestore = require("geofirestore").GeoFirestore;

Let me know if that works for you.

ghost commented 5 years ago

Yeah, it works now. That was the issue. Thanks!

stot3 commented 5 years ago

So what would you use if you are using Angular, Typescript and this does not work like,

import {Geofirestore} from 'geofirestore';