MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.

Home Page:https://geofirestore.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple documents by id

molimauro opened this issue · comments

Hello, thanks for the amazing library.

I was wondering if I can query multiple documents by id using something similar to firebase.firestore.FieldPath.documentId(). I tried also with geofirestore.FieldPath.documentId() without success.
Can someone point me in the right direction?

Thanks in advance.

So geofirestore only replicates the functionality of a firestore instance (firebase.firestore()) not the firestore namespace (firebase.firestore). So If you want to create FieldPath objects you'll need to use the namespace (firebase.firestore). However you can use a FieldPath object in geofirestore to make a query.

I think that helps, let me know!

Thanks for the quick reply. I tried with:

const query = geocollection
    .where(firebase.firestore.FieldPath.documentId(), "in", [
        "2EELdMWlmpBYpw4l8Jxr",
        "2mvgJlCEXhTcNfeyfm6f",
    ])
    .get()

but I got this error:

index.cjs.js:160 Uncaught FirebaseError: Function Query.where() called with invalid data. Invalid field path (d.[object Object]). Paths must not contain '~', '*', '/', '[', or ']'

If I try this:

const query = firestore
    .collection("collection")
    .where(firebase.firestore.FieldPath.documentId(), "in", [
        "2EELdMWlmpBYpw4l8Jxr",
        "2mvgJlCEXhTcNfeyfm6f",
    ])
    .get()

This obviously works but I get the documents with the default firestore data structure instead of the geofirestore structure.

Am I missing something? Or there is another way to retrieve multiple documents by id?
Thanks.

Can you please create a stackblitz example? Use this as a template if you'd like https://stackblitz.com/fork/geofirestore-issue-sandbox

Hi, I found out that I was stuck at version 3.4.3. With the latest version the problem seems gone. Thanks for your help!