MichaelSolati / geofirestore-js

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

firebase geofirestore v9 not working #231

Closed andresfmm closed 2 years ago

andresfmm commented 2 years ago

hi michael hou are you?

this code not working firebase is working but geofirestore return TypeError: undefined is not a function

firebase web sdk with react native

import { initializeApp } from "firebase/app";
import { 
    getFirestore, 
    initializeFirestore,
    collection, 
    addDoc, 
    getDocs } from "@firebase/firestore";

import { getAuth, signInWithEmailAndPassword } from "firebase/auth";    

const firebaseConfig = {
    apiKey: "xxx",
    authDomain: "xxx",
    databaseURL: "xxx",
    projectId: "xxx",
    storageBucket: "xxx",
    messagingSenderId: "xxx",
    appId: "xxx",
    measurementId: "xxx"
};

const app = initializeApp(firebaseConfig);

const db = initializeFirestore(app, {
    experimentalForceLongPolling: true
})

const GeoFirestore = geofirestore.initializeApp(db);

export {
    db,
    getDocs,
    collection,
    getAuth,
    signInWithEmailAndPassword,
    GeoFirestore
}

error here the error is undefine the code break here stop here

const geocollection = await GeoFirestore.collection('users').where("status", "==", status)

const geoQuery = geocollection.near({
    center: new db.GeoPoint(latitude, longitude),
    radius: 10,
});

// Get query (as Promise)
const idcollection = await geoQuery.get();

i hope some one can help me

thanks a lot

MichaelSolati commented 2 years ago

Support for the modular firestore library doesn't exist yet, see here, for now you need to use the compat library.

Modular support is being worked on, see here.

I'm closing this issue in favor of #219