@umituz/react-native-firebase 2.4.16 → 2.4.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-firebase",
3
- "version": "2.4.16",
3
+ "version": "2.4.17",
4
4
  "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -42,6 +42,21 @@ export abstract class BaseRepository implements IPathResolver {
42
42
  return getFirestore();
43
43
  }
44
44
 
45
+ /**
46
+ * Get the Firestore instance or throw error
47
+ * @throws Error if repository is destroyed or Firestore is not initialized
48
+ */
49
+ protected getDbOrThrow(): Firestore {
50
+ if (this.state === RepositoryState.DESTROYED) {
51
+ throw new Error(ERROR_MESSAGES.REPOSITORY.DESTROYED);
52
+ }
53
+ const db = getFirestore();
54
+ if (!db) {
55
+ throw new Error(ERROR_MESSAGES.FIRESTORE.NOT_INITIALIZED);
56
+ }
57
+ return db;
58
+ }
59
+
45
60
  getUserCollection(userId: string): CollectionReference<DocumentData> | null {
46
61
  const db = this.getDb();
47
62
  if (!db) return null;