diff --git a/packages/firestore/e2e/firestore.e2e.js b/packages/firestore/e2e/firestore.e2e.js index 9d584b6d1d..1df4f838dc 100644 --- a/packages/firestore/e2e/firestore.e2e.js +++ b/packages/firestore/e2e/firestore.e2e.js @@ -1011,5 +1011,18 @@ describe('firestore()', function () { events.forEach(event => event.should.equal('sync')); }); }); + + describe('non-default db', function () { + it('should be able to initialize a non-default db on mobile platforms', async function () { + // Not supported on web lite sdk + if (!Platform.other) { + const { initializeFirestore } = firestoreModular; + const { getApp } = modular; + const app = getApp('secondaryFromNative'); + const db = await initializeFirestore(app, { persistence: false }, 'test2ndDb'); + db.customUrlOrRegion.should.equal('test2ndDb'); + } + }); + }); }); }); diff --git a/packages/firestore/lib/index.js b/packages/firestore/lib/index.js index 6e72a38193..41746aa8df 100644 --- a/packages/firestore/lib/index.js +++ b/packages/firestore/lib/index.js @@ -97,6 +97,11 @@ class FirebaseFirestoreModule extends FirebaseModule { persistence: true, }; } + + get customUrlOrRegion() { + return this._customUrlOrRegion; + } + // We override the FirebaseModule's `eventNameForApp()` method to include the customUrlOrRegion eventNameForApp(...args) { return `${this.app.name}-${this._customUrlOrRegion}-${args.join('-')}`; diff --git a/packages/firestore/lib/modular/index.js b/packages/firestore/lib/modular/index.js index 132587b662..141bdc8404 100644 --- a/packages/firestore/lib/modular/index.js +++ b/packages/firestore/lib/modular/index.js @@ -210,10 +210,9 @@ export function waitForPendingWrites(firestore) { * @param {string?} databaseId * @returns {Promise} */ -export async function initializeFirestore(app, settings /* databaseId */) { - // TODO(exaby73): implement 2nd database once it's supported +export async function initializeFirestore(app, settings, databaseId) { const firebase = getApp(app.name); - const firestore = firebase.firestore(); + const firestore = firebase.firestore(databaseId); await firestore.settings.call(firestore, settings, MODULAR_DEPRECATION_ARG); return firestore; }