I'd like to write a CLI script that copies some data from our live app to a local firestore emulator, for development and testing purposes.
The docs say that you should set the FIRESTORE_EMULATOR_HOST environment variable to connect to a local emulator -- but that doesn't allow the same app to connect to the server as well.
I've tried this:
const onlineApp = await admin.initializeApp(
{
credential: admin.credential.applicationDefault(),
databaseURL: 'https://....firebaseio.com',
},
'default'
);
process.env['FIRESTORE_EMULATOR_HOST'] = 'localhost:8080';
const emulator = await admin.initializeApp(
{
projectId: 'emulator',
},
'emulator'
);
... but then onlineApp no longer talks to the online Firestore.
Is there another way to do this so I can create a connection to both at the same time?