2

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.

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.