Closed uslperera closed 6 years ago
Duplicate of #43 the docs should have been updated to explain this, I'd advise looking at my answer
https://github.com/geofirestore/geofirestore-js/issues/43#issuecomment-428469214
Thanks mate. Your answer saved my day. It would have been better if docs have clearly stated it.
43 (comment)
Hi MichaelSolati, In react native on listner not working...
@KSRajkumar45 I'd need to see some code as an example as well as your package.json. hopefully I can help from there
Hi Micheal,
I have tested this and i am also seeing the same behaviour in which the code is returning all documents, how is i use the following code below i get the correct results.
const collectionRef = firebase.firestore().collection('Consents').orderBy('g').startAt(2)
const geoFirestore = new
GeoFirestore(collectionRef.where('d.details.ConsentType',"==",consentType))
const geoQuery = geoFirestore.query({
center: new firebase.firestore.GeoPoint(lat, long),
radius: val,
});
geoQuery.on("key_entered",function($key, result) {
console.log(key+result)
}
});
On a second note are we able to use firestore pagination as mention in the doc here https://firebase.google.com/docs/firestore/query-data/query-cursors with the library and if so can you point me to any working example ?
saw the correction uder #43 however i would still like to know if Pagination is possible with the lib
Pagination is not available. The library effectively does a form of pagination based on the geohash in order to do the query, and since we can not stack startAt
(or other similar orderBy
modifiers). We also can't do a limit
because of how this is an aggregation of queries.
This part of the docs explains in detail why we can't do those two things. However in v3.1.0 you will have limit
. I do first need to get through v3.0.0 as it's a massive rewrite, and I'm going through writing tests for it now.
While limit
isn't in my current codebase for v3.0.0, you can test it via:
npm install geofirestore/geofirestore-js#v3.0.0
This is very much not guaranteed to be solid, but I do think it works well for what it is, and most kinks have been ironed out.
Paging does not remain possible even if you have a limit?
Following code returns all the documents
Since the radius has been set to 1 km, it should only return the documents within that range. But this is not working as expected. Can you please let me know if the above code is correct?