Skip to content

Instantly share code, notes, and snippets.

@mimming
Created September 18, 2014 00:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mimming/d0272f5cf3b8953b49c0 to your computer and use it in GitHub Desktop.
Save mimming/d0272f5cf3b8953b49c0 to your computer and use it in GitHub Desktop.
Rename a key in firebase across many nodes
var ref = new Firebase("https://<your-firebase>.firebaseio.com/path-to-your-node");
ref.on("child_added", function(snap) {
var data = snap.val();
data.phonenumber = data.contact;
delete data.contact;
ref.child(snap.name()).set(data, function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
@WillDeStijl
Copy link

This needs to be updated for the newer version of Firebase. For example, snap.name() has been deprecated, and I'm not too sure about that "data.phonenumber" syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment