Created
January 27, 2019 14:20
-
-
Save NickFoden/1fe3eb03282c66193cae9be88e9f29e5 to your computer and use it in GitHub Desktop.
Copy Firebase RTDB Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fbCopy(oldRef, newRef) { | |
return Promise((resolve, reject) => { | |
oldRef.once('value').then(snap => { | |
return newRef.set(snap.val()); | |
}).then(() => { | |
console.log('Done!'); | |
resolve(); | |
}).catch(err => { | |
console.log(err.message); | |
reject(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment