File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -1011,5 +1011,18 @@ describe('firestore()', function () {
1011
1011
events . forEach ( event => event . should . equal ( 'sync' ) ) ;
1012
1012
} ) ;
1013
1013
} ) ;
1014
+
1015
+ describe ( 'non-default db' , function ( ) {
1016
+ it ( 'should be able to initialize a non-default db on mobile platforms' , async function ( ) {
1017
+ // Not supported on web lite sdk
1018
+ if ( ! Platform . other ) {
1019
+ const { initializeFirestore } = firestoreModular ;
1020
+ const { getApp } = modular ;
1021
+ const app = getApp ( 'secondaryFromNative' ) ;
1022
+ const db = await initializeFirestore ( app , { persistence : false } , 'test2ndDb' ) ;
1023
+ db . customUrlOrRegion . should . equal ( 'test2ndDb' ) ;
1024
+ }
1025
+ } ) ;
1026
+ } ) ;
1014
1027
} ) ;
1015
1028
} ) ;
Original file line number Diff line number Diff line change @@ -103,6 +103,11 @@ class FirebaseFirestoreModule extends FirebaseModule {
103
103
persistence : true ,
104
104
} ;
105
105
}
106
+
107
+ get customUrlOrRegion ( ) {
108
+ return this . _customUrlOrRegion ;
109
+ }
110
+
106
111
// We override the FirebaseModule's `eventNameForApp()` method to include the customUrlOrRegion
107
112
eventNameForApp ( ...args ) {
108
113
return `${ this . app . name } -${ this . _customUrlOrRegion } -${ args . join ( '-' ) } ` ;
Original file line number Diff line number Diff line change @@ -210,10 +210,9 @@ export function waitForPendingWrites(firestore) {
210
210
* @param {string? } databaseId
211
211
* @returns {Promise<Firestore> }
212
212
*/
213
- export async function initializeFirestore ( app , settings /* databaseId */ ) {
214
- // TODO(exaby73): implement 2nd database once it's supported
213
+ export async function initializeFirestore ( app , settings , databaseId ) {
215
214
const firebase = getApp ( app . name ) ;
216
- const firestore = firebase . firestore ( ) ;
215
+ const firestore = firebase . firestore ( databaseId ) ;
217
216
await firestore . settings . call ( firestore , settings , MODULAR_DEPRECATION_ARG ) ;
218
217
return firestore ;
219
218
}
You can’t perform that action at this time.
0 commit comments