Skip to content

Instantly share code, notes, and snippets.

@irshu355
Last active September 21, 2018 04:09
Show Gist options
  • Save irshu355/791aa90ed5eea6175b7b2e3690b7ed43 to your computer and use it in GitHub Desktop.
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.
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