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.
Related
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 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).
I've seen a post on how to create a Map in the Firebase console for the realtime database, but how do you create a Map (in order to create a mutable/queryable list structure) in Firebase from the console? This is in order to create dummy data without doing so from the client.
Firestore documents are essentially JSON, and JSON doesn't have a native map data type. The most direct mapping is to create a JSON object:
Now you can add the keys and values under the new field.
You can now create a map type in Firebase:
So, I'm developing an app that takes in raw data from Google Sheets and sorts it in an appropriate manner.
Functionality that I'm looking for:
If a row gets added in the google sheets, the appropriate data needs to be added to my Firebase database. Next, I need to check if the field 'email' in this new data already exists. If it does, I need to ignore it and if it doesn't, create a new field. If I use ValueEventListener for this purpose, each time the data is added, it returns the whole list. How do I use ChildEventListener in this case?
My data structure:
You can assume that the 'email' will always be at '3', 'mobile code' at '4' and so on.
I am not sure how to retrieve the data with ChildEventListener as the path keeps changing for each person. However, the data is successfully being added from the google sheets to the Firebase so you can ignore that part.
Somehow in my firebase account 2 sets of data have changed the fieldname for 'DeviceID' to 'PeripheralID' and 'DeviceUUID'. Is there a way that I can search these and change them to be 'DeviceID'? I would prefer to do this by command line but will do whatever is easier.
Im thinking something along the line of firebase update:database ?
To answer the question with comments under question:
There is no tool for it. You'll have to download the data from database, edit JSON with some kind of text editor and upload it back to database.
This operation OVERRIDES information in database with information in JSON. In other words: uploading JSON changes database.
If you're using firebase console and data you want to change is not in whole database, you could open certain tree level and do those operation just there.