4
votes

I'm already using Firebase Realtime database, but now Firebase has launched Cloud Firestore for database so, how can I transfer my data from realtime database to firestore as I already have users and they are using realtime database on the android app.

So, is there a way that I can transfer the database to firestore?

4
This is a duplicate question. Please see stackoverflow.com/questions/46639693/…Thomas David Kehoe

4 Answers

2
votes

If you're looking for a magic button that can convert your database from the Realtime Database to Cloud Firestore, there isn't one! And as far as I read, Firebase creators won't create one. So unfortunately, you'll need to convert the database yourself.

1
votes

Firebase has published a guide for migrating from Realtime Database to Cloud Firestore.

Edit: It seems they have changed that page. Here is a cached version of their migration guide published earlier.

0
votes

I don't recommend you changing now, its is still in its BETA version and they are coming up with new things every now and then. I suggest to wait. Let them make up their mind first :P

0
votes

i made a script for converting data from firebase to firestore

import { AngularFirestore, AngularFirestoreCollection } from 'angularfire2/firestore';
import { AngularFireDatabase } from 'angularfire2/database';
constructor(
private afs: AngularFirestore,
private angularfire: AngularFireDatabase
) { }convert() {
this.itemsCollection = this.afs.collection('requests'); //ref()
this.angularfire.list('/requests/').auditTrail().subscribe((data: any) => {
  _.each(data, element => {
    this.itemsCollection.doc(element.key).set(element.payload.val())
      .then((result) => {
      });
  });
});}