I want to export multiple separated collections to another user in postman.
How can I do that? How can I select multiple collections at a time while exporting them in postman?
Unfortunately not. You have 3 different way to copy your multiple Collections to an other Client.
Export each collection as one single file (Contra: can be time-Consuming)
Export Whole Postman Dump over File->Settings->Data (Contra: You must delete some collections, environment- and global variables afterwards)
Share Your Collections over the Postman cloud (Contra: depending on the amount: you have to pay for it).
Related
Say I have the following structure:
collectionA/documentA/collectionB/documentB
But I have set documentB directly to the above path (without explicitly creating collectionA, documentA or collectionB), so the document "documentA" is a non existent document that does not show in queries if I list all documents of collectionA even with admin sdk.
However the firebase web console somehow manages to list such documents. Not only that, I have also seen a third party app Firefoo list such documents and somehow even paginate the results. How can I achieve this?
Turns out this can be achieved with the
Firestore REST API v1
using the listDocuments endpoint and setting query param showMissing to true.
All Firestore queries are based on having some data about that document present in the index that is used for the query. There is no public API to show non-existing documents.
The Firebase console shows these documents based on getting a list of all collections, and then building a data model from that.
My firestore collection is structured as follows:
events/{2022}/January/{someDocumentId}
How do I only export January subcollection?
I've been trough these docs https://firebase.google.com/docs/firestore/manage-data/export-import, but can only find info on exporting entire database and "events" root collections. The reason is I want to keep my cost down.
How do I only export January subcollection?
You can filter specific collections by using the collection-id flag. Following the link you've already provided, you can follow the command that was provided:
gcloud firestore export gs://[BUCKET_NAME] --collection-ids=[COLLECTION_ID_1],[COLLECTION_ID_2]
Just a note, using collection-id flag is used to import specific collection groups from a set of export files, and if there's a collection that you don't want to export, you can exclude them from the export operation by using the flag.
Additionally, if you want to backup the whole collection and its sub collections without using the collection-id flag, you can use collection group query which retrives all the documents from a collection group instead from a single collection. There's also a related post that has a good answers on how to fecth all documents from a Firebase collection using collection group query.
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.
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.
I accidentally made a mistake in a firestore collection name and would like to rename it but there is no option to rename a collection in firestore. There is an option to export and then import the collection to GCP using the following command:
gcloud firestore export gs://[BUCKET_NAME] --collection-ids=[COLLECTION_ID_1],[COLLECTION_ID_2]
Will this only reexport the collection with the same name. Is there any other way to do this other than writing a script or doing it manually?
If you want to change the names and IDs of collections and documents (or in other words, change the path of the document), the only way to do that is to read each document, then write it to its new location. This typically involves writing code to perform a query, iterate the results, write new documents, and delete the originals.
Unless you are able to find a library to do all this for you, you'll have to write the code yourself.
when I import JSON data into firebase using import option on the GUI, the data is loaded into firebase in alphabet order. But I need data to be loaded in the order I have in JSON. Does anyone know a way to load JSON data into firebase DB in the order the data in JSON file.
The console always shows children in that order. That's just how the console works.
If you need ordering in your app, your query should indicate the order of results using one of the ordering methods.