Comments (15)
Probably the same reason as in #19, try to update firebase.
from geofirestore-js.
This package isn't designed for react-native-firebase
, it's designed for the pure JavaScript firebase
library. Unfortunately it will not work. (I am open to PRs for support though)
from geofirestore-js.
Hi, @MichaelSolati Just to let you know if you don't already. I am using react-native-firebase and geofirestore(2.2.1) seems to be working fine with it, I can read and write.
Thank you very much for this library it's very helpful and easy to use! keep it up, please ! :)
from geofirestore-js.
@graig12 In Firebase docs, they usually do array-contains using a string
parameter. Your code is using an array, I'm not sure if that's the problem.
Try:
query: (ref) => ref.where('d.name', 'array-contains',arr.join(' '))
edit: However, this checks that the array at d.name
contains an element with 'cat dog'
What you seem to want to achieve is to do a 'OR' operator on the array of names against the DB, which is unfortunately not achievable with a single query in Firebase.
from geofirestore-js.
As written at the bottom of the docs:
Logical OR queries. In this case, you should create a separate query for each OR condition and merge the query results in your app.
You'll have to query for every element in the array and merge the results:
var arr =['cat','dog']
var results = []
arr.forEach(el => {
const geoQuery = geoFirestore.query({
center: new firebase.firestore.GeoPoint(lat, long),
radius: val,
query: (ref) => ref.where('d.name', '==', el)
})
geoQuery.on('key_entered', function(key, document, distance) {
results.append(document)
});
})
This is assuming that you want the results in random order and it is probably not performant because geo query will need to run n times. I would suggest you to just get data from a single geo query and filter the data client side.
from geofirestore-js.
HI @joscmw95 thanks for the input i will try and share the results.
from geofirestore-js.
@MvRemmerden i am using react-native-firebase package so i have to update it...
from geofirestore-js.
@MichaelSolati thanks when i use firebase its work.
from geofirestore-js.
@MichaelSolati Will the package work for firebase-admin sdk???
from geofirestore-js.
@kenzdozz it should with versions 5.x.x
.
from geofirestore-js.
Hi Michael,
Great job on the library. I am using firestore "firebase": "^4.13.1" along with geofirestore "^2.2.2".
I am trying to accomplish the following query using array-contains. I have the following array example below.
array=['cat','dog'];
now i want to loop via firestore and do something like a
.where('d.name','array-contains',array). See my query below for reference.
const collectionRef = firebase.firestore().collection('Consents')
const geoFirestore = new GeoFirestore(collectionRef);
var arr =['cat','dog']
const geoQuery = geoFirestore.query({
center: new firebase.firestore.GeoPoint(lat, long),
radius: val,
query: (ref) => ref.where('d.name', 'array-contains',arr)
});
how can i achieve this using geofirestore, firebase and firestore.
from geofirestore-js.
should i update my firebase to react native firebase to be able to use the array contains
method along with geofirestore?
from geofirestore-js.
that is correct @joscmw95 i want to achieve an OR. Since this is not possible can how would
u suggest i accomplish this ?
from geofirestore-js.
Hi @joscmw95 are you able to share any insight here on this post of stack over flow."https://stackoverflow.com/questions/53094022/firestore-multiple-where-query?noredirect=1#comment93100280_53094022" I am attempting
to do a filter on a geofirestore/firestore database that conatians a collection of books. I am trying to filter on booktype and book age however i am getting the error "uncaught error in onsnapshot firebaseError: cursor position is outside the range of the original query " the code that i am using is below.
const collectionRef = firebase.firestore().collection('Books')
collectionRef.where('d.details.BookType',"==",BookType)
collectionRef = collectionRef.where('d.details.bookage',"<=",age)
collectionRef = collectionRef.orderBy('d.details.bookage')
const geoFirestore = new GeoFirestore(collectionRef)
const geoQuery = geoFirestore.query({
center: new firebase.firestore.GeoPoint(lat, long),
radius: val,
});
geoQuery.on("key_entered",function(key, coords, distance) {
storeCoordinate(key,coords.coordinates._lat,coords.coordinates._long,newdata)
});
from geofirestore-js.
Internally geoFirestore gets its results by using startAt
and endAt
. The way you declare your collectionRef clashes with how it works hence the cursor error.
Detailed explanation in stackoverflow
from geofirestore-js.
Related Issues (20)
- Question - how can I find near documents with each unique radius? HOT 11
- How to write to firestore after geofirestore query HOT 1
- can't write to firestore properly after geofirestore query HOT 1
- StartAt or startAfter support HOT 1
- Query speed HOT 6
- Custom document key HOT 1
- Geoqueries with additional queries? HOT 3
- When querying `near`: `distance` prop is missing when distance is 0 HOT 1
- Support for Firebase JS SDK 9 HOT 9
- customKey not working on read HOT 10
- Pass a custom document ID HOT 1
- Query returning zero results when filtering with where HOT 8
- Support for new firestore 9.x? HOT 1
- runTransaction on a collection (server-side using cloud functions) HOT 1
- firebase geofirestore v9 not working HOT 1
- Bug double removed on a marker HOT 1
- Geofirestore and onSnapshot are giving delayed events - information is not updating properly
- Unsubscribe from GeoQuery.onSnapshot on document deletion HOT 1
- Typescript errors when trying to deploy function HOT 2
- Is there a way to update the criteria of GeoQuery ? Rather then making a new one
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geofirestore-js.