MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

Query returns no documents #108

Closed chrisjaimesdev closed 5 years ago

chrisjaimesdev commented 5 years ago

I have the following code in a react native project

 import firebase from 'firebase';
 import { GeoFirestore } from "geofirestore";

                           .
                           .
                           .

 var geofirestoreRef = new GeoFirestore(firebase.firestore());

 const geocollection = geofirestoreRef.collection('users');

  geocollection.near({
    center: new firebase.firestore.GeoPoint(37.33233141, -122.0312186),
    radius: 1000
  }).get().then((geousers) => {
    console.log("users in area ob: ", geousers.docs);
  }).catch(() => {
    console.log("error when querying users with geolocation");
  });

Also I have 3 documents in my users collection with the following field

Screen Shot 2019-05-17 at 11 51 48 PM

however every time I run it, I am getting an empty snapshot with no users in the then() block. Am I missing something here?

chrisjaimesdev commented 5 years ago

ok just realized I have to use Geofirestore to insert the doc so that the obj has the proper structure ;)

MichaelSolati commented 5 years ago

@chrisjaimesdev this is something I'm working on, a bit of a change in how I "index" data so it's easier for people new to geofirestore to use. But that will probably be out next month...

chrisjaimesdev commented 5 years ago

@MichaelSolati awesome! can't wait for newer versions :) thank you!