Closed jerryheir closed 5 years ago
Can I see a stackblitz? (Also have you checked the console? It may be an indexing issue.)
Okay. const firestore = admin.firestore(), geofirestore: GeoFirestore = new GeoFirestore(firestore), geocollection: GeoCollectionReference = geofirestore.collection('cloud'), query: GeoQuery = geocollection .where("cloudId", "==", "203j28n2mw") .where("status", "==", true) .near({ center: new admin.firestore.GeoPoint(6.4589556, 3.6085704), radius: 10 });
Even when I do it without the near method, it still doesnt work const firestore = admin.firestore(), geofirestore: GeoFirestore = new GeoFirestore(firestore), geocollection: GeoCollectionReference = geofirestore.collection('cloud'), query: GeoQuery = geocollection .where("cloudId", "==", "203j28n2mw") .where("status", "==", true);
const value = await query.get();
It always only returns [], empty array
So this should/would normally work, and if it's not working for you I'll need to see more of the environment you're working in. If you can provide a sample app or a stackblitz that would be helpful and necessary.
https://stackblitz.com/edit/typescript-rtnjz3
It's a firebase cloud function. It is run in a try catch, nothing breaks. Its just that it returns [], The url about is the stackblitz editor so you can have an idea of what is basically there. Thanks for your response, I really appreciate
Again code looks good, but I can't execute/run this code, it don't have a firebase project. Can you make this a basic web app or something I can execute to test or see what's happening? Here, you can modify this, https://stackblitz.com/edit/typescript-qg74c8?file=index.ts I just need your app variables so it'll initialize.
Jeez, I updated it with real values And it worked. How come
import * as firebase from 'firebase/app'; import 'firebase/firestore'; Only difference is that you use the above, how can I get that working on a firebase cloud function. It doesnt let me
TypeError: firebase.firestore is not a function
Unhandled error Error: Unknown error status: TypeError: firebase.firestore is not a function
You're doing this in a cloud function you said? What version of admin/function are you using?
My friend @MichaelSolati It worked now.So the imports was the problem, Its been a while I did Typescript and this cloud functions is in typescript i was doing this
import * as firebase from 'firebase/app'; import 'firebase/firestore';
Just as I saw in the examples, when I should have been doing
import { firebase } from '@firebase/app'; import '@firebase/firestore'; I thank you for all you have done. Without replicating the issue I wouldn't have seen the bug. Thanks a lot
The firebase admin also works. Just tested it.
Please help. whenever I add .where to my query, docs always return empty when it exists. geocollection: GeoCollectionReference = geofirestore.collection('ewnb') .where("dhhshs", "==", true) .where("hhjhshjs", "==", "iool jhhe"); This simple query return empty when I see it clearly in the db