'Firebase Cloud function using multiple projects
Is it possible to have a single cloud function query data from 2 different Firebase projects. I'd want to mirror changes performed in "my-app" project's Firestore to "my-app-backup" project's Firestore.
Solution 1:[1]
You can initialize multiple Admin apps in a Cloud function as shown below:
// Initialize the default app
initializeApp(defaultAppConfig);
const otherApp = initializeApp(otherAppConfig, 'other');
const defaultFirestore = getFirestore();
const otherFirestore = getFirestore(otherApp);
Here you can use defaultFirestore to read from first Firestore project and then otherFirestore to write in another.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharmaraj |
