Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FieldPath.documentId doesn't exist #1117

Open
dsgriffin opened this issue Jul 8, 2021 · 5 comments
Open

FieldPath.documentId doesn't exist #1117

dsgriffin opened this issue Jul 8, 2021 · 5 comments

Comments

@dsgriffin
Copy link

dsgriffin commented Jul 8, 2021

Do you want to request a feature or report a bug?

Bug

(If this is a usage question, please do not post it here—post it on gitter. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

What is the current behavior?

FieldPath does not exist on FieldPath when retrieving via the useFirestore hook.

What is the expected behavior?

Trying to retrieve multiple documents in one go via in inside useFirestoreConnect e.g. this should work:

const firestore = useFirestore();
    
useFirestoreConnect(() => [{
    collection: 'examples',
    where: [firestore.FieldPath.documentId(), 'in', ['a', 'b']],
    storeAs: 'examples'
}]);

But the only property that exists on FieldPath currently is isEqualTo.

If I try to use firebase directly e.g.

import firebase from '../settings';

useFirestoreConnect(() => [{
    collection: 'examples',
    where: [firebase.firestore.FieldPath.documentId(), 'in', ['a', 'b']],
    storeAs: 'examples'
}]);

I get a ton of type issues and cannot proceed.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

Latest Stable (3.10.0)

@Gsiete
Copy link

Gsiete commented Jul 14, 2021

Did you see this?
prescottprue/redux-firestore#176

@dsgriffin
Copy link
Author

Did you see this?
prescottprue/redux-firestore#176

yep, I've been using where: ['__name__', '==', ...] as it's the only working solution currently, but a bit of a hack.

@prescottprue
Copy link
Owner

Not sure why the statics wouldn't be available on the instance returned from useFirestore, but you should be able to be pull straight from the firebase SDK (since it is just a static):

import firebase from 'firebase/app'
import 'firebase/firestore'

// Then later
firebase.firestore.FieldPath.documentId()

@dsgriffin Thanks for sharing the workaround, that is also valid!

@dsgriffin
Copy link
Author

@prescottprue no worries!

just tried using firebase.firestore.FieldPath.documentId() inside useFirestoreConnect's where clause.

discovered that type WhereOptions expects a string as the first argument, while documentId() returns a FieldPath. using a toString() on it might be a solution

@fseha-hagos
Copy link

it works for me....

import firebase from firebase/firestore

const collectionRef = collection(db, 'myData');
const q = query(collectionRef, where(firebase.documentId(), 'in', ['a', 'b']));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants