Search code examples
angularfirebaseionic3google-cloud-firestoreangularfire2

access another firestore data in angularfire2


I am holding 2 firebase projects(A & B) having data in firestore and not in realtime. My use case is I need to access other project's firestore data. A app should be able to read & write B's firestore and vice-versa.

I tried like let's take from A app standpoint, we can access A's firestore data using public afs: AngularFirestore that comes from the constructor. But to access B's firestore data, I tried to initialize the config and take angularfirestore reference like below.

const secondApp = firebase.initializeApp({
          apiKey: "xxxxxxxxxxxxxxxxxxx",
          authDomain: "xxxxxxxxxxxxxxxxxx",
          databaseURL: "xxxxxxxxxxxxxxxx",
          storageBucket: "xxxxxxxxxxxxxxx",
          messagingSenderId: "xxxxxxxxxxxx",
          projectId: "xxxxxxxxxx"
          });
const secondAfS = new AngularFirestore(secondApp );

Then it ended up by throwing the error as Expected 6 arguments, but got 1.

I am not sure about the parameters required for constructor but just tried. So the error says(To me), Does it works if we supply required 6 parameters?

Is this kind of use case achievable? if so, please correct me. Otherwise, please advise me the workaround.


Solution

  • At this point, I did not find an option to call another firestore database but we can call another realtime database. So I managed to achieve my functionality by adding database triggers in realtime database of another app.