Skip to content

Instantly share code, notes, and snippets.

@mvuksano
Forked from katowulf/firebase_copy.js
Last active August 29, 2015 14:14
Show Gist options
  • Save mvuksano/e2779d63c2f804f0cb36 to your computer and use it in GitHub Desktop.
Save mvuksano/e2779d63c2f804f0cb36 to your computer and use it in GitHub Desktop.
function copyFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
function moveFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( !error ) { oldRef.remove(); }
else if( typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment