dalenguyen / firestore-backup-restore

NPM package for backup and restore Firebase Firestore
https://firebaseopensource.com/projects/dalenguyen/firestore-backup-restore/
MIT License
493 stars 83 forks source link

Only [DEFAULT] firebase app is recognized #153

Open rrust opened 1 year ago

rrust commented 1 year ago

When FireBase is initialized with a name for the app like this:

initializeFirebaseApp(serviceAccount, 'foo');

I'm getting: Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.

When using the firebase initializeApp() function like this:

initializeApp({ credential }, 'foo');

restore() for example fails with a "firebase is not initialized" error.

The only way to make it work for now is to call:

initializeApp({ credential }, '[DEFAULT]');

right before using any functions from this package.

The problem might be that throughoput this library everytime when getFirestore() is called it is done so without the name of the initialized app, which should be getFirestore(getApp(''foo")).

dalenguyen commented 1 year ago

Hi @rrust, I updated the package.

When initializing the app, it will return a firestore instance. You can use it to pass to the functions.

const firestore = initializeFirebaseApp(serviceAccount, 'foo');

// backup(firestore,....)