Last active
September 21, 2018 04:09
-
-
Save irshu355/791aa90ed5eea6175b7b2e3690b7ed43 to your computer and use it in GitHub Desktop.
Sample of how to export data from your existing firebase realtime database to firestorm.
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
var config = { | |
apiKey: "xxxxxxxxx", | |
authDomain: "xxxxxxx", | |
databaseURL: "https://xxxxxxx.firebaseio.com", | |
projectId: "xxxxxxx", | |
storageBucket: "xxxxxx.appspot.com", | |
messagingSenderId: "xxxxxxxxxx" | |
}; | |
firebase.initializeApp(config); | |
const db = firebase.firestore().app.database(); | |
var hotels = db.ref("hotels"); | |
cafes.on('child_added', function(data) { | |
console.log(data.val()); | |
writeToFirestore(data.val()); | |
}); | |
function writeToFirestore(obj){ | |
var db = firebase.firestore(); | |
db.collection("hotels").add(obj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment