Firebase: Update key?
11,572
There is no way to change the key of an existing node.
So instead I'd go for:
var ref = new Firebase('https://my.firebaseio.com/');
var child = ref.child('43268jfjn7983-347983');
child.once('value', function(snapshot) {
ref.child('somethingElse').set(snapshot.val());
child.remove();
});
Related videos on Youtube
Author by
blablabla
Updated on June 06, 2022Comments
-
blablabla about 2 years
{ 43268jfjn7983-347983: { title: 'hello world', time: '1000' } }
As above, I just want to update
43268jfjn7983-347983
to something else, is this possible in firebase? -
blablabla over 9 yearsThanks, I guess that will do.
-
sampoh over 7 yearsLike said in the answer, this solution can't really be used in a production environment. The procedure is just too slow.
-
evu about 7 years@sampoh would a solution to this be to have two DBs in sync and just switch the ref if you need to update one then switch it back after changing and uploading Jason?
-
sampoh about 7 years@evu, you are not going to be fast enough. The problem is that there might be constant requests to Firebase on production env. When you are done importing, you may have already lost data that was modified in the master DB during the JSON edit.