1

With gcloud, it's very straightforward to export all documents within a firestore project, or specific collections within a project. (See here for more). However, I'm trying to export solely one document from within a collection. Is that at all possible? I can't seem to find any documentation on this.

thisissami
  • 15,445
  • 16
  • 47
  • 74

1 Answers1

0

As per my investigation, the feature to export a single document within a collection is not supported. You can find the feature request in the public issue tracker. You can go ahead and subscribe/star the request for additional updates/workarounds from the product team.

A workaround that’s possible is that you can use SubCollection that comes under the root level Collection to export. You will have to make sure to name the sub collections uniquely. Firestore will export these as a flat list and two sub collections with the same id/name will be combined. To do this you can first create a subcollection under the main collection and then add the documents that needs to be exported, and use the following command to export the subcollection:

gcloud beta firestore export gs://export_123 --collection-ids = ’sub-collectionID1’ , ’sub-collectionID2’

Another possible workaround is that you can export the whole collection to cloud storage, then load the data from firestore export it to the big query , and then use jquery or any other JSON tool that you prefer to extract the document that you require.

Zeenath S N
  • 1,100
  • 2
  • 8