How to change this value name in Firebase Databse? [duplicate] - firebase

I am using Firebase-Unity beta tool for real time data in my app. I want to change node names in the tree without override its children. For example:
IFirebase firebase;
firebase = Firebase.CreateNew ("https://test1.firebaseio.com/someChild");
firebase_Rank.Child("ChilOne").SetValue(1);
firebase_Rank.Child("ChilTwo").SetValue(2);
firebase_Rank.Child("ChilThree").SetValue(3);
In this kind of tree is it possible to change the names of "ChildOne" without override it's value.

The Firebase Database has no way to rename an existing node.
Most developers accomplish a rename by inserting a copy of the node with the new name and then deleting the old node.

Related

How can I change the name of database in Cloud Firestore

how to change the name of database in firebase
Can we change the name of a database in Cloud Firestore? I didn't give name to the database. I want to change the name of the database from
sample-51580 to sample. In the Firebase console, I could not find a way to do this.
The name you're showing in your screenshot if the project ID. There is no way to modify this ID once a project has been created. If you want a different project ID, you'll have to create a new project.
This does like a XY problem though, so you might want to think/explain what underlying problem you're trying to solve here.

Is there a way to change realtime database field names when fetching them in a web app

I am using a firebase realtime database on my android app, and there is an option to change the naming of the fields of a class with PropertyName.
https://firebase.google.com/docs/reference/android/com/google/firebase/database/PropertyName
Is there a way to achieve something similar in a web app?
No, the names of the properties in the resulting object will always match the names of the children in the database. If you don't want different property names in the object, you'll have to manually create a new object that looks the way you want.

How to give the name to the child node in firebase

Whenever i will upload the data to the firebase it give random name to the child node. In the image "Upload" this name in given by me but what about inside name i want to change the name of inside the upload root how i can do that
The name inside the Upload is generated using push(), that you are using in your code, that is why you see it.
push() is a method that creates a random id to be able to seperate records in the database and also to be able to easily identify records in the Firebase Database.
push()
Create a reference to an auto-generated child location. The child key is generated client-side and incorporates an estimate of the server's time for sorting purposes. Locations generated on a single client will be sorted in the order that they are created, and will be sorted approximately in order across all clients.
more info here: https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference.html#push()

How to not generate unique ID when using push method in Firebase?

I'm trying to push new data into Firebase but it keeps generating an unique ID and an extra child node for me. How can I stop generating the ID and extra node or is there another way to push data into Firbase? My dataset is given and I just need to dump the dataset into the db. (But I'm slowly updating this given dataset.)
Firease always generates the unique id when using the push method. You can use it as a key or as a parent node. This post describes push in more detail.
https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html
You should use set to publish new data to firebase if push doesn't fit your use case. There is also an update method as set will overwrite any data in the given path.
https://firebase.google.com/docs/database/web/save-data
I generally use set for new data, or if I change how I have my data structured, or if I am appending new data in a path, update to make changes to fields for a dataset, and push for sets of data that I want organized in a list by time( i.e. Chat message log ).

Sync related data using angularfire/collection

I want to use angularfirecollection to keep one-way sync with a list of data. The structure is a list of 'things' with various properties (e.g. 'Likes') and users who each hold a subset of 'things' keys (e.g. -jsdzsdrestofkey: true). U
sing angularfirecollection (or firebase native 'on'), I can sync up all things that a particular user has... I can also grab (using firebase native 'once') each 'thing''s properties to display.
In angular, however, I need to use $apply() to inject the property data into scope for each item in the user's 'thing' list. To keep things in sync, I suppose I can use firebase's on change event... But this all requires me to create new references for each thing in a user's list.
What is the best way to approach grabbing relational data in firebase, while keeping both the list and the relational data in sync?
Thanks!
Irfaan
If I understand correctly, it sounds like you should use FirebaseIndex and feed the index directly into an angularFireCollection. Then you wouldn't need to use $apply since the thing data will already be in the $scope, and everything will stay synced:
var index = new FirebaseIndex(fb.child('users/789/thing_list'), fb.child('things'));
$scope.things = angularFireCollection(index);
// $scope.things will contain the user's things with the associated thing data

Resources