1

I import a large amount of JSON files to my FireBase DB console with this feature: https://github.com/firebase/firebase-import

It works well when I upload arrays with lots of objects, but if i want to upload a new array object to existing table, it overrides the existing object instead of adding the new one.

I would be happy to find a right way to "Update" the new objects to the existing table with firebase-import or any other tool.

1

1 Answer 1

2

As pointed out by Jen, you can use the Firebase CLI to update objects in your database. Just use this command:

firebase database:update /path/to/object -d newArray.json

where:

  • /path/to/object - the path of the object that you want to update.
  • newArray.json - the json file containing the array with the new values.
Sign up to request clarification or add additional context in comments.

5 Comments

I didn't even think of that. Great answer @JenPerson and Rosário!
The SLI works great but when i use this command: firebase:database:push /tradingDaysT date.json its not create the correct child key order. For example, in this imgbb.com/]https://image.ibb.co/dTTPZ6/ex.png it's creates this child name "--L39RnfnFR_bDDccsoLR" Instead of creating "1" thank you very much
What the push function does is create a unique key. And not increment the previous key. If you want to have incremented keys you should add the desired key to your json file and use database:update instead
Thank you , Is there any way to increment the key automatically ? I mean, if in the database I have a keys of "0" , "1", "2". The next key that will come up with the CLI will be "3"? It is not feasible to add a keys manually in a JSON files
Unfortunately, Firebase doesn't have a way to do that yet. You'd have to figure out a way for yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.