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.

Arik5
  • 37
  • 1
  • 6

1 Answers1

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.
  • I didn't even think of that. Great answer @JenPerson and Rosário! – Frank van Puffelen Jan 18 '18 at 00:17
  • 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 https://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 – Arik5 Jan 18 '18 at 18:14
  • 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 – Rosário Pereira Fernandes Jan 18 '18 at 18:17
  • 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 – Arik5 Jan 21 '18 at 13:59
  • Unfortunately, Firebase doesn't have a way to do that yet. You'd have to figure out a way for yourself. – Rosário Pereira Fernandes Jan 21 '18 at 17:02