Closed stubborncoder closed 6 years ago
I don't think this is a Geofirestore question as much as this is a Firebase Functions question. Either way, I'd tell you to do more research and reading the docs of firebase functions, because you dont need to import * as firebase from 'firebase';
And if you need to create a collectionref for geofirestore you could do...
import * as admin from 'firebase-admin';
const collectionRef = admin.firestore().collection('collection');
I know that admin is the normal way to query collections un cloud functions however if you try to assign that collectionRef to a new Geofirestore(collectionRef), you will get a casting error as Geofirestore "firebase.firestore.CollectionReference", firebase-admin's collection type "FirebaseFirestore.CollectionReference", In another thread @invention7 sugested to import firebase package instead of admin, but as I show you before even importing Geofirestore as its simplest way throws that error at build.
I agree with @stubborncoder that firebase-admin's 'collection' type appears to be incompatible with the collection type expected by the geofirestore constructor. To get around this, I created by collectionRef with the 'firebase' library.
Maybe, @MichaelSolati , there is an opportunity for Geofirestore in expanding the constructor to allow the firebase-admin's collection... but in terms of David's immediate need, I think it can be handled as-s.
@stubborncoder, in your firebase config, have you disabled persistence?
e.g. PersistenceEnabled: false ?
Hi @invention7 my firebaseconfig wasn't modified at all, it's just as it's created by the firebase CLI... thanks for your help!, Edited: don't really know if this setting comes as false or true by default...
I'd be open to a PR if anyone wants to expand the types allowed. I'd also ask that the PR is made towards the dev
branch.
Hey @stubborncoder, sorry I missed your comment... try downgrading firebase to '5.0.0' (ie 'npm install firebase@5.0.0')
In general I can probably double type everything (it would just take a while to get through). You should also be able to // @ts-ignore
type issues for now. While it's not the end all be all solution, it should work until I dual type everything.
@invention7 that did the trick m8, I downgraded as you suggested and now it builds and runs without any further issues!. Thank you very much!.
np @stubborncoder ! Good luck!!
oh wow! awesome @MichaelSolati !
Thank you @invention7 !
For everyone else, Firebase Functions should work (may need to make a small patch, but for the most part it's good to go). Try npm i geofirestore@2.1.0
Hello, I'm still struggling with this, maybe you can help,
When I execute 'npm run build' no matter if I comment out the firebase import, it will trigger the following error that I googled and couldn't find any specific answer, the error will only dissapear if I comment out the geofirestore import...
package.json
"dependencies": { "firebase": "^5.0.4", "firebase-admin": "~5.12.1", "firebase-functions": "^1.0.4", "geofirestore": "^1.2.0" },