Giter VIP home page Giter VIP logo

Comments (15)

MvRemmerden avatar MvRemmerden commented on May 31, 2024 1

Probably the same reason as in #19, try to update firebase.

from geofirestore-js.

MichaelSolati avatar MichaelSolati commented on May 31, 2024 1

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.

AndrewAi avatar AndrewAi commented on May 31, 2024 1

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.

joscmw95 avatar joscmw95 commented on May 31, 2024 1

@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.

joscmw95 avatar joscmw95 commented on May 31, 2024 1

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.

graig12 avatar graig12 commented on May 31, 2024 1

HI @joscmw95 thanks for the input i will try and share the results.

from geofirestore-js.

ektasahu027 avatar ektasahu027 commented on May 31, 2024

@MvRemmerden i am using react-native-firebase package so i have to update it...

from geofirestore-js.

ektasahu027 avatar ektasahu027 commented on May 31, 2024

@MichaelSolati thanks when i use firebase its work.

from geofirestore-js.

kenzdozz avatar kenzdozz commented on May 31, 2024

@MichaelSolati Will the package work for firebase-admin sdk???

from geofirestore-js.

MichaelSolati avatar MichaelSolati commented on May 31, 2024

@kenzdozz it should with versions 5.x.x.

from geofirestore-js.

graig12 avatar graig12 commented on May 31, 2024

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.

graig12 avatar graig12 commented on May 31, 2024

should i update my firebase to react native firebase to be able to use the array contains
method along with geofirestore?

from geofirestore-js.

graig12 avatar graig12 commented on May 31, 2024

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.

graig12 avatar graig12 commented on May 31, 2024

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.

joscmw95 avatar joscmw95 commented on May 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.