budibase icon indicating copy to clipboard operation
budibase copied to clipboard

Cannot get ID of firestore document

Open phiresky opened this issue 3 years ago • 1 comments

Describe the feature request

It's possible to get a list of documents in a firestore collection. But the documents only contain the fields in the document, not the IDs of the document. This appears to me to make it impossible to do anything slightly complex since you can't actually reference the documents you're getting.

I think the issue is that budibase immediately calls .data() on each document

https://github.com/Budibase/budibase/blob/b0f94d1ad3dec60085f359a85314dad0c9090ab6/packages/server/src/integrations/firebase.ts#L137

so it's not possible to get the id or meta data of each document (see https://firebase.google.com/docs/reference/node/firebase.firestore.DocumentSnapshot)

phiresky avatar Aug 02 '22 15:08 phiresky

I can confirm that changing the above code to snapshot.forEach(doc => result.push({...id: doc.id, doc.data()})) fixes the issue

phiresky avatar Aug 08 '22 13:08 phiresky

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Oct 12 '22 09:10 stale[bot]

To add to this one, it would be good to have the option to use a custom ID when creating a doc.

melohagan avatar Aug 30 '23 15:08 melohagan