@react-native-firebase/firestore 20.2.1 → 20.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/__tests__/firestore.test.ts +292 -1
  3. package/android/src/main/java/io/invertase/firebase/firestore/UniversalFirebaseFirestoreCommon.java +17 -9
  4. package/android/src/main/java/io/invertase/firebase/firestore/UniversalFirebaseFirestoreModule.java +28 -26
  5. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java +53 -22
  6. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCommon.java +5 -2
  7. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreDocumentModule.java +35 -21
  8. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreEvent.java +5 -1
  9. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreModule.java +48 -16
  10. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreQuery.java +3 -1
  11. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreSerialize.java +13 -8
  12. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreTransactionModule.java +12 -7
  13. package/ios/RNFBFirestore/RNFBFirestoreCollectionModule.m +78 -49
  14. package/ios/RNFBFirestore/RNFBFirestoreCommon.h +6 -2
  15. package/ios/RNFBFirestore/RNFBFirestoreCommon.m +23 -10
  16. package/ios/RNFBFirestore/RNFBFirestoreDocumentModule.m +41 -11
  17. package/ios/RNFBFirestore/RNFBFirestoreModule.m +66 -15
  18. package/ios/RNFBFirestore/RNFBFirestoreSerialize.h +5 -3
  19. package/ios/RNFBFirestore/RNFBFirestoreSerialize.m +17 -10
  20. package/ios/RNFBFirestore/RNFBFirestoreTransactionModule.m +21 -7
  21. package/lib/FirestorePersistentCacheIndexManager.js +34 -0
  22. package/lib/index.d.ts +32 -1
  23. package/lib/index.js +25 -2
  24. package/lib/modular/index.d.ts +52 -0
  25. package/lib/modular/index.js +55 -3
  26. package/lib/version.js +1 -1
  27. package/lib/web/RNFBFirestoreModule.js +61 -34
  28. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [20.4.0](https://github.com/invertase/react-native-firebase/compare/v20.3.0...v20.4.0) (2024-08-13)
7
+
8
+ ### Features
9
+
10
+ - **firestore:** support for `PersistentCacheIndexManager` ([#7910](https://github.com/invertase/react-native-firebase/issues/7910)) ([0b0de45](https://github.com/invertase/react-native-firebase/commit/0b0de45513cd3aab9f7037fd8468a63cf96aa62c))
11
+ - **firestore:** support for second database ([#7949](https://github.com/invertase/react-native-firebase/issues/7949)) ([eec08a0](https://github.com/invertase/react-native-firebase/commit/eec08a06f41dd96d13778fbed2afcaaac238fca4))
12
+
13
+ ## [20.3.0](https://github.com/invertase/react-native-firebase/compare/v20.2.1...v20.3.0) (2024-07-19)
14
+
15
+ **Note:** Version bump only for package @react-native-firebase/firestore
16
+
6
17
  ## [20.2.1](https://github.com/invertase/react-native-firebase/compare/v20.2.0...v20.2.1) (2024-07-17)
7
18
 
8
19
  ### Bug Fixes
@@ -1,6 +1,61 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import firestore, { firebase, Filter } from '../lib';
3
+ import firestore, {
4
+ firebase,
5
+ Filter,
6
+ getFirestore,
7
+ addDoc,
8
+ doc,
9
+ collection,
10
+ collectionGroup,
11
+ setDoc,
12
+ updateDoc,
13
+ enableNetwork,
14
+ disableNetwork,
15
+ clearPersistence,
16
+ terminate,
17
+ waitForPendingWrites,
18
+ initializeFirestore,
19
+ setLogLevel,
20
+ runTransaction,
21
+ getCountFromServer,
22
+ loadBundle,
23
+ namedQuery,
24
+ writeBatch,
25
+ Bytes,
26
+ FieldPath,
27
+ FieldValue,
28
+ deleteField,
29
+ serverTimestamp,
30
+ arrayUnion,
31
+ arrayRemove,
32
+ increment,
33
+ GeoPoint,
34
+ query,
35
+ where,
36
+ or,
37
+ and,
38
+ orderBy,
39
+ startAt,
40
+ startAfter,
41
+ endAt,
42
+ endBefore,
43
+ limit,
44
+ limitToLast,
45
+ getDoc,
46
+ getDocFromCache,
47
+ getDocFromServer,
48
+ getDocs,
49
+ getDocsFromCache,
50
+ getDocsFromServer,
51
+ deleteDoc,
52
+ onSnapshot,
53
+ Timestamp,
54
+ getPersistentCacheIndexManager,
55
+ deleteAllPersistentCacheIndexes,
56
+ disablePersistentCacheIndexAutoCreation,
57
+ enablePersistentCacheIndexAutoCreation,
58
+ } from '../lib';
4
59
 
5
60
  const COLLECTION = 'firestore';
6
61
 
@@ -372,6 +427,12 @@ describe('Firestore', function () {
372
427
  return expect(e.message).toContain("'queryName' must be a non-empty string");
373
428
  }
374
429
  });
430
+ });
431
+
432
+ describe('modular', function () {
433
+ it('`getFirestore` function is properly exposed to end user', function () {
434
+ expect(getFirestore).toBeDefined();
435
+ });
375
436
 
376
437
  it('`Filter` is properly exposed to end user', async function () {
377
438
  const filter1 = Filter('name', '==', 'Tim');
@@ -384,5 +445,235 @@ describe('Firestore', function () {
384
445
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
385
446
  const query2 = Filter.or(filter1, filter2);
386
447
  });
448
+
449
+ it('`doc` function is properly exposed to end user', function () {
450
+ expect(doc).toBeDefined();
451
+ });
452
+
453
+ it('`collection` function is properly exposed to end user', function () {
454
+ expect(collection).toBeDefined();
455
+ });
456
+
457
+ it('`collectionGroup` function is properly exposed to end user', function () {
458
+ expect(collectionGroup).toBeDefined();
459
+ });
460
+
461
+ it('`setDoc` function is properly exposed to end user', function () {
462
+ expect(setDoc).toBeDefined();
463
+ });
464
+
465
+ it('`updateDoc` function is properly exposed to end user', function () {
466
+ expect(updateDoc).toBeDefined();
467
+ });
468
+
469
+ it('`addDoc` function is properly exposed to end user', function () {
470
+ expect(addDoc).toBeDefined();
471
+ });
472
+
473
+ it('`enableNetwork` function is properly exposed to end user', function () {
474
+ expect(enableNetwork).toBeDefined();
475
+ });
476
+
477
+ it('`disableNetwork` function is properly exposed to end user', function () {
478
+ expect(disableNetwork).toBeDefined();
479
+ });
480
+
481
+ it('`clearPersistence` function is properly exposed to end user', function () {
482
+ expect(clearPersistence).toBeDefined();
483
+ });
484
+
485
+ it('`terminate` function is properly exposed to end user', function () {
486
+ expect(terminate).toBeDefined();
487
+ });
488
+
489
+ it('`waitForPendingWrites` function is properly exposed to end user', function () {
490
+ expect(waitForPendingWrites).toBeDefined();
491
+ });
492
+
493
+ it('`initializeFirestore` function is properly exposed to end user', function () {
494
+ expect(initializeFirestore).toBeDefined();
495
+ });
496
+
497
+ it('`setLogLevel` function is properly exposed to end user', function () {
498
+ expect(setLogLevel).toBeDefined();
499
+ });
500
+
501
+ it('`runTransaction` function is properly exposed to end user', function () {
502
+ expect(runTransaction).toBeDefined();
503
+ });
504
+
505
+ it('`getCountFromServer` function is properly exposed to end user', function () {
506
+ expect(getCountFromServer).toBeDefined();
507
+ });
508
+
509
+ it('`loadBundle` function is properly exposed to end user', function () {
510
+ expect(loadBundle).toBeDefined();
511
+ });
512
+
513
+ it('`namedQuery` function is properly exposed to end user', function () {
514
+ expect(namedQuery).toBeDefined();
515
+ });
516
+
517
+ it('`writeBatch` function is properly exposed to end user', function () {
518
+ expect(writeBatch).toBeDefined();
519
+ });
520
+
521
+ it('`Bytes` class is properly exposed to end user', function () {
522
+ expect(Bytes).toBeDefined();
523
+ });
524
+
525
+ it('`FieldPath` class is properly exposed to end user', function () {
526
+ expect(FieldPath).toBeDefined();
527
+ });
528
+
529
+ it('`FieldValue` is properly exposed to end user', function () {
530
+ expect(FieldValue).toBeDefined();
531
+ });
532
+
533
+ it('`deleteField` function is properly exposed to end user', function () {
534
+ expect(deleteField).toBeDefined();
535
+ });
536
+
537
+ it('`serverTimestamp` function is properly exposed to end user', function () {
538
+ expect(serverTimestamp).toBeDefined();
539
+ });
540
+
541
+ it('`arrayUnion` function is properly exposed to end user', function () {
542
+ expect(arrayUnion).toBeDefined();
543
+ });
544
+
545
+ it('`arrayRemove` function is properly exposed to end user', function () {
546
+ expect(arrayRemove).toBeDefined();
547
+ });
548
+
549
+ it('`increment` function is properly exposed to end user', function () {
550
+ expect(increment).toBeDefined();
551
+ });
552
+
553
+ it('`GeoPoint` is properly exposed to end user', function () {
554
+ expect(GeoPoint).toBeDefined();
555
+ });
556
+
557
+ it('`query` function is properly exposed to end user', function () {
558
+ expect(query).toBeDefined();
559
+ });
560
+
561
+ it('`where` function is properly exposed to end user', function () {
562
+ expect(where).toBeDefined();
563
+ });
564
+
565
+ it('`or` function is properly exposed to end user', function () {
566
+ expect(or).toBeDefined();
567
+ });
568
+
569
+ it('`and` function is properly exposed to end user', function () {
570
+ expect(and).toBeDefined();
571
+ });
572
+
573
+ it('`orderBy` function is properly exposed to end user', function () {
574
+ expect(orderBy).toBeDefined();
575
+ });
576
+
577
+ it('`startAt` function is properly exposed to end user', function () {
578
+ expect(startAt).toBeDefined();
579
+ });
580
+
581
+ it('`startAfter` function is properly exposed to end user', function () {
582
+ expect(startAfter).toBeDefined();
583
+ });
584
+
585
+ it('`endAt` function is properly exposed to end user', function () {
586
+ expect(endAt).toBeDefined();
587
+ });
588
+
589
+ it('`endBefore` function is properly exposed to end user', function () {
590
+ expect(endBefore).toBeDefined();
591
+ });
592
+
593
+ it('`limit` function is properly exposed to end user', function () {
594
+ expect(limit).toBeDefined();
595
+ });
596
+
597
+ it('`limitToLast` function is properly exposed to end user', function () {
598
+ expect(limitToLast).toBeDefined();
599
+ });
600
+
601
+ it('`getDoc` function is properly exposed to end user', function () {
602
+ expect(getDoc).toBeDefined();
603
+ });
604
+
605
+ it('`getDocFromCache` function is properly exposed to end user', function () {
606
+ expect(getDocFromCache).toBeDefined();
607
+ });
608
+
609
+ it('`getDocFromServer` function is properly exposed to end user', function () {
610
+ expect(getDocFromServer).toBeDefined();
611
+ });
612
+
613
+ it('`getDocs` function is properly exposed to end user', function () {
614
+ expect(getDocs).toBeDefined();
615
+ });
616
+
617
+ it('`getDocsFromCache` function is properly exposed to end user', function () {
618
+ expect(getDocsFromCache).toBeDefined();
619
+ });
620
+
621
+ it('`getDocsFromServer` function is properly exposed to end user', function () {
622
+ expect(getDocsFromServer).toBeDefined();
623
+ });
624
+
625
+ it('`deleteDoc` function is properly exposed to end user', function () {
626
+ expect(deleteDoc).toBeDefined();
627
+ });
628
+
629
+ it('`onSnapshot` function is properly exposed to end user', function () {
630
+ expect(onSnapshot).toBeDefined();
631
+ });
632
+
633
+ it('`Timestamp` is properly exposed to end user', function () {
634
+ expect(Timestamp).toBeDefined();
635
+ });
636
+
637
+ it('`getPersistentCacheIndexManager` is properly exposed to end user', function () {
638
+ expect(getPersistentCacheIndexManager).toBeDefined();
639
+ const indexManager = getPersistentCacheIndexManager(firebase.firestore());
640
+ expect(indexManager!.constructor.name).toEqual('FirestorePersistentCacheIndexManager');
641
+ });
642
+
643
+ it('`deleteAllPersistentCacheIndexes` is properly exposed to end user', function () {
644
+ expect(deleteAllPersistentCacheIndexes).toBeDefined();
645
+ });
646
+
647
+ it('`disablePersistentCacheIndexAutoCreation` is properly exposed to end user', function () {
648
+ expect(disablePersistentCacheIndexAutoCreation).toBeDefined();
649
+ });
650
+
651
+ it('`enablePersistentCacheIndexAutoCreation` is properly exposed to end user', function () {
652
+ expect(enablePersistentCacheIndexAutoCreation).toBeDefined();
653
+ });
654
+ });
655
+
656
+ describe('FirestorePersistentCacheIndexManager', function () {
657
+ it('is exposed to end user', function () {
658
+ const firestore1 = firebase.firestore();
659
+ firestore1.settings({ persistence: true });
660
+ const indexManager = firestore1.persistentCacheIndexManager();
661
+ expect(indexManager).toBeDefined();
662
+ expect(indexManager.constructor.name).toEqual('FirestorePersistentCacheIndexManager');
663
+
664
+ expect(indexManager.enableIndexAutoCreation).toBeInstanceOf(Function);
665
+ expect(indexManager.disableIndexAutoCreation).toBeInstanceOf(Function);
666
+ expect(indexManager.deleteAllIndexes).toBeInstanceOf(Function);
667
+
668
+ const firestore2 = firebase.firestore();
669
+ firestore2.settings({ persistence: false });
670
+
671
+ const nullIndexManager = firestore2.persistentCacheIndexManager();
672
+
673
+ expect(nullIndexManager).toBeNull();
674
+
675
+ const nullIndexManagerModular = getPersistentCacheIndexManager(firestore2);
676
+ expect(nullIndexManagerModular).toBeNull();
677
+ });
387
678
  });
388
679
  });
@@ -29,8 +29,13 @@ import java.util.WeakHashMap;
29
29
  public class UniversalFirebaseFirestoreCommon {
30
30
  static WeakHashMap<String, WeakReference<FirebaseFirestore>> instanceCache = new WeakHashMap<>();
31
31
 
32
- static FirebaseFirestore getFirestoreForApp(String appName) {
33
- WeakReference<FirebaseFirestore> cachedInstance = instanceCache.get(appName);
32
+ static String createFirestoreKey(String appName, String databaseId) {
33
+ return appName + ":" + databaseId;
34
+ }
35
+
36
+ static FirebaseFirestore getFirestoreForApp(String appName, String databaseId) {
37
+ String firestoreKey = createFirestoreKey(appName, databaseId);
38
+ WeakReference<FirebaseFirestore> cachedInstance = instanceCache.get(firestoreKey);
34
39
 
35
40
  if (cachedInstance != null) {
36
41
  return cachedInstance.get();
@@ -38,24 +43,27 @@ public class UniversalFirebaseFirestoreCommon {
38
43
 
39
44
  FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
40
45
 
41
- FirebaseFirestore instance = FirebaseFirestore.getInstance(firebaseApp);
46
+ FirebaseFirestore instance = FirebaseFirestore.getInstance(firebaseApp, databaseId);
42
47
 
43
- setFirestoreSettings(instance, appName);
48
+ setFirestoreSettings(instance, firestoreKey);
44
49
 
45
50
  instanceCache.put(appName, new WeakReference<FirebaseFirestore>(instance));
46
51
 
47
52
  return instance;
48
53
  }
49
54
 
50
- private static void setFirestoreSettings(FirebaseFirestore firebaseFirestore, String appName) {
55
+ private static void setFirestoreSettings(
56
+ FirebaseFirestore firebaseFirestore, String firestoreKey) {
51
57
 
52
58
  UniversalFirebasePreferences preferences = UniversalFirebasePreferences.getSharedInstance();
53
59
  FirebaseFirestoreSettings.Builder firestoreSettings = new FirebaseFirestoreSettings.Builder();
54
60
 
55
- String cacheSizeKey = UniversalFirebaseFirestoreStatics.FIRESTORE_CACHE_SIZE + "_" + appName;
56
- String hostKey = UniversalFirebaseFirestoreStatics.FIRESTORE_HOST + "_" + appName;
57
- String persistenceKey = UniversalFirebaseFirestoreStatics.FIRESTORE_PERSISTENCE + "_" + appName;
58
- String sslKey = UniversalFirebaseFirestoreStatics.FIRESTORE_SSL + "_" + appName;
61
+ String cacheSizeKey =
62
+ UniversalFirebaseFirestoreStatics.FIRESTORE_CACHE_SIZE + "_" + firestoreKey;
63
+ String hostKey = UniversalFirebaseFirestoreStatics.FIRESTORE_HOST + "_" + firestoreKey;
64
+ String persistenceKey =
65
+ UniversalFirebaseFirestoreStatics.FIRESTORE_PERSISTENCE + "_" + firestoreKey;
66
+ String sslKey = UniversalFirebaseFirestoreStatics.FIRESTORE_SSL + "_" + firestoreKey;
59
67
 
60
68
  int cacheSizeBytes =
61
69
  preferences.getIntValue(
@@ -17,6 +17,7 @@ package io.invertase.firebase.firestore;
17
17
  *
18
18
  */
19
19
 
20
+ import static io.invertase.firebase.firestore.UniversalFirebaseFirestoreCommon.createFirestoreKey;
20
21
  import static io.invertase.firebase.firestore.UniversalFirebaseFirestoreCommon.getFirestoreForApp;
21
22
  import static io.invertase.firebase.firestore.UniversalFirebaseFirestoreCommon.instanceCache;
22
23
 
@@ -40,27 +41,28 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
40
41
  super(context, serviceName);
41
42
  }
42
43
 
43
- Task<Void> disableNetwork(String appName) {
44
- return getFirestoreForApp(appName).disableNetwork();
44
+ Task<Void> disableNetwork(String appName, String databaseId) {
45
+ return getFirestoreForApp(appName, databaseId).disableNetwork();
45
46
  }
46
47
 
47
- Task<Void> enableNetwork(String appName) {
48
- return getFirestoreForApp(appName).enableNetwork();
48
+ Task<Void> enableNetwork(String appName, String databaseId) {
49
+ return getFirestoreForApp(appName, databaseId).enableNetwork();
49
50
  }
50
51
 
51
- Task<Void> useEmulator(String appName, String host, int port) {
52
+ Task<Void> useEmulator(String appName, String databaseId, String host, int port) {
52
53
  return Tasks.call(
53
54
  getExecutor(),
54
55
  () -> {
55
- if (emulatorConfigs.get(appName) == null) {
56
- emulatorConfigs.put(appName, "true");
57
- getFirestoreForApp(appName).useEmulator(host, port);
56
+ String firestoreKey = createFirestoreKey(appName, databaseId);
57
+ if (emulatorConfigs.get(firestoreKey) == null) {
58
+ emulatorConfigs.put(firestoreKey, "true");
59
+ getFirestoreForApp(appName, databaseId).useEmulator(host, port);
58
60
  }
59
61
  return null;
60
62
  });
61
63
  }
62
64
 
63
- Task<Void> settings(String appName, Map<String, Object> settings) {
65
+ Task<Void> settings(String firestoreKey, Map<String, Object> settings) {
64
66
  return Tasks.call(
65
67
  getExecutor(),
66
68
  () -> {
@@ -70,7 +72,7 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
70
72
 
71
73
  UniversalFirebasePreferences.getSharedInstance()
72
74
  .setIntValue(
73
- UniversalFirebaseFirestoreStatics.FIRESTORE_CACHE_SIZE + "_" + appName,
75
+ UniversalFirebaseFirestoreStatics.FIRESTORE_CACHE_SIZE + "_" + firestoreKey,
74
76
  Objects.requireNonNull(cacheSizeBytesDouble).intValue());
75
77
  }
76
78
 
@@ -78,7 +80,7 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
78
80
  if (settings.containsKey("host")) {
79
81
  UniversalFirebasePreferences.getSharedInstance()
80
82
  .setStringValue(
81
- UniversalFirebaseFirestoreStatics.FIRESTORE_HOST + "_" + appName,
83
+ UniversalFirebaseFirestoreStatics.FIRESTORE_HOST + "_" + firestoreKey,
82
84
  (String) settings.get("host"));
83
85
  }
84
86
 
@@ -86,7 +88,7 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
86
88
  if (settings.containsKey("persistence")) {
87
89
  UniversalFirebasePreferences.getSharedInstance()
88
90
  .setBooleanValue(
89
- UniversalFirebaseFirestoreStatics.FIRESTORE_PERSISTENCE + "_" + appName,
91
+ UniversalFirebaseFirestoreStatics.FIRESTORE_PERSISTENCE + "_" + firestoreKey,
90
92
  (boolean) settings.get("persistence"));
91
93
  }
92
94
 
@@ -94,7 +96,7 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
94
96
  if (settings.containsKey("ssl")) {
95
97
  UniversalFirebasePreferences.getSharedInstance()
96
98
  .setBooleanValue(
97
- UniversalFirebaseFirestoreStatics.FIRESTORE_SSL + "_" + appName,
99
+ UniversalFirebaseFirestoreStatics.FIRESTORE_SSL + "_" + firestoreKey,
98
100
  (boolean) settings.get("ssl"));
99
101
  }
100
102
 
@@ -104,7 +106,7 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
104
106
  .setStringValue(
105
107
  UniversalFirebaseFirestoreStatics.FIRESTORE_SERVER_TIMESTAMP_BEHAVIOR
106
108
  + "_"
107
- + appName,
109
+ + firestoreKey,
108
110
  (String) settings.get("serverTimestampBehavior"));
109
111
  }
110
112
 
@@ -112,25 +114,25 @@ public class UniversalFirebaseFirestoreModule extends UniversalFirebaseModule {
112
114
  });
113
115
  }
114
116
 
115
- LoadBundleTask loadBundle(String appName, String bundle) {
117
+ LoadBundleTask loadBundle(String appName, String databaseId, String bundle) {
116
118
  byte[] bundleData = bundle.getBytes(StandardCharsets.UTF_8);
117
- return getFirestoreForApp(appName).loadBundle(bundleData);
119
+ return getFirestoreForApp(appName, databaseId).loadBundle(bundleData);
118
120
  }
119
121
 
120
- Task<Void> clearPersistence(String appName) {
121
- return getFirestoreForApp(appName).clearPersistence();
122
+ Task<Void> clearPersistence(String appName, String databaseId) {
123
+ return getFirestoreForApp(appName, databaseId).clearPersistence();
122
124
  }
123
125
 
124
- Task<Void> waitForPendingWrites(String appName) {
125
- return getFirestoreForApp(appName).waitForPendingWrites();
126
+ Task<Void> waitForPendingWrites(String appName, String databaseId) {
127
+ return getFirestoreForApp(appName, databaseId).waitForPendingWrites();
126
128
  }
127
129
 
128
- Task<Void> terminate(String appName) {
129
- FirebaseFirestore firebaseFirestore = getFirestoreForApp(appName);
130
-
131
- if (instanceCache.get(appName) != null) {
132
- instanceCache.get(appName).clear();
133
- instanceCache.remove(appName);
130
+ Task<Void> terminate(String appName, String databaseId) {
131
+ FirebaseFirestore firebaseFirestore = getFirestoreForApp(appName, databaseId);
132
+ String firestoreKey = createFirestoreKey(appName, databaseId);
133
+ if (instanceCache.get(firestoreKey) != null) {
134
+ instanceCache.get(firestoreKey).clear();
135
+ instanceCache.remove(firestoreKey);
134
136
  }
135
137
 
136
138
  return firebaseFirestore.terminate();