How can I get uid of all documents if I use useFirestoreCollectionData hook ? #257
-
Version infoReact: Firebase: ReactFire: Other (e.g. Node, browser, operating system) (if applicable): Test caseAfter fetching all the documents from a collection, if i want to update one document, how can I do it? I think it will require document uid for this. There is no way to get document ids of all documents. Is is possible to pass a flag to useFirestoreCollection and useFirestoreCollectionData which will do this:
Steps to reproduceExpected behaviorActual behavior |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @catrawalkar , reactfire/sample/src/Firestore.js Line 74 in 68cfc79 This will add an [
{
commonName: 'Giraffe',
id: 'theDocumentId' // the key is `id` because we set `idField` to "id"
}
] It looks like the reference is missing this information. Sorry about that! Any chance you have a moment to create a PR for that? Otherwise I can add it :) |
Beta Was this translation helpful? Give feedback.
-
@jhuleatt Sure, I will try to create a PR for this. What other things can be configured using config object? Also, before opening an issue, i tried a lot to figure out if this is possible by digging out in the code. I was not able to figure out due to lack of RxJS, TS know how..! Can you help me with good resources to learn these things so I can contribute here? |
Beta Was this translation helpful? Give feedback.
-
Great! Re: learning: It might help if I explain the source of reactfire/reactfire/firestore/index.tsx Lines 111 to 116 in 68cfc79 The Lines 1 to 4 in 68cfc79 It uses RxFire's |
Beta Was this translation helpful? Give feedback.
Hi @catrawalkar ,
useFirestoreCollectionData
accepts a config object that allows you to add an id field to each object in the array it returns. The sample shows how this is done:reactfire/sample/src/Firestore.js
Line 74 in 68cfc79
This will add an
id
key to every result. The returned objects will look like this:It looks like the reference is missing this information. Sorry about that! Any chance you have a moment to create a PR for that? Otherwise I can add it :)