Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually inserting data in Firebase

Tags:

firebase

I am creating an app using Angular.js and Firebase and until I have the interface in working order, I am planning on manually inserting data. While it's easy enough to add key:value pairs, I haven't been able to figure out how to structure multiple levels of data, like adding an object which has multiple entries inside of it. If I import a json file, it does this, but I do not want to have to edit a json file and upload it everytime I want to make a change. Is there a way to do this that I am unaware of?

like image 661
Alex Getty Avatar asked May 22 '13 16:05

Alex Getty


People also ask

How do you populate a Firebase database?

You can populate firebase Database from a JavaScript file by taking database ref to firebase and pushing objects to it.

Why my data is not stored in Firebase?

Nothing is getting stored, because you are not storing anything, you need to use setValue() to store data. The child() gets reference to a location in the database.

How do I insert data into Firebase using Python?

Insert record in firebaseImport library of Firebase in Python script. Then, create database connection using the below command. FirebaseApplication takes two parameters; one is URL of database and second is authentication details for database. But we don't have any rules so we are passing None.


2 Answers

If you head to Firebase Forge (at https://[your-firebase].firebaseio.com), you can load up the Graphical Debugger for your Firebase and manually add, modify, or remove data, as well as watch it as it changes in real-time.

To add hierarchical data using Forge, using the + button to create a new child attribute, give it a name and leave the value blank, and then use the + button on the child to begin adding more children or child attributes. When you're ready to save your data, use the Add button, or hit [Enter].

like image 172
Rob DiMarco Avatar answered Oct 02 '22 12:10

Rob DiMarco


An interface that would efficiently and quickly edit a hierarchy of data would naturally need to anticipate that hierarchy. So you're not going to find a pre-built tool to edit tiered data without tedious data entry.

Generally, I keep a second browser window opened, logged in with admin privileges, and just manually input the objects using the browser's debugger (e.g. Firebug). I find this quite a bit faster than import/export of JSON (and writing JSON is so tedious!).

Generally, I prefer update over set, as this means I can just enter the changes rather than having to write out the entire hierarchy:

new Firebase(MY_URL).child(PATH).update({    // replace the widgets    widgets: {       one: { color: 'red', shape: 'square' },       two: { color: 'green', shape: 'triangle' }    },     // reset the count    widgetCount: 0,     // delete my status    status: null }); 

If neither the Forge tools nor inputting via debugger suits you, then you might find it worth the investment to write a quick and dirty, ugly and primitive, admin page where you can alter the data and save it.

I have several of these, which I whipped up in around an hour each, to use for frequent admin routines on our sites. The trick is to build only what you need and not get caught up in how cool and awesome it could be. Spartan FTW.

like image 23
Kato Avatar answered Oct 02 '22 11:10

Kato