-
-
Notifications
You must be signed in to change notification settings - Fork 341
Adding the option to select the firestore database #1645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…tring
Allow useFirestore to accept a database string directly as a simpler alternative to the options object. The function now supports both calling patterns:
- useFirestore(databaseName)
- useFirestore({ name?, database? })
When passed a string, it uses the default Firebase app with the specified database. This provides a more convenient API for the common use case of specifying only a database name.
WalkthroughThe changes add IDE metadata to version control exclusions and refactor the Firestore accessor function to support dual invocation modes: accepting either a database string directly or an options object with optional name and database parameters, with type-aware implementation routing. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant useFirestore
participant TypeCheck as Type Detection
participant Firebase as Firebase Init
rect rgb(240, 248, 255)
Note over Caller,Firebase: Invocation Mode 1: String
Caller->>useFirestore: useFirestore("mydb")
useFirestore->>TypeCheck: typeof string?
TypeCheck-->>useFirestore: yes
useFirestore->>Firebase: getFirestore(useFirebaseApp(), "mydb")
Firebase-->>useFirestore: Firestore instance
useFirestore-->>Caller: return Firestore
end
rect rgb(245, 245, 220)
Note over Caller,Firebase: Invocation Mode 2: Options Object
Caller->>useFirestore: useFirestore({ name: "app", database: "mydb" })
useFirestore->>TypeCheck: typeof object?
TypeCheck-->>useFirestore: yes, has database
useFirestore->>Firebase: getFirestore(useFirebaseApp("app"), "mydb")
Firebase-->>useFirestore: Firestore instance
useFirestore-->>Caller: return Firestore
end
rect rgb(255, 250, 240)
Note over Caller,Firebase: Invocation Mode 3: Name-only Options
Caller->>useFirestore: useFirestore({ name: "app" })
useFirestore->>TypeCheck: typeof object, no database?
TypeCheck-->>useFirestore: yes
useFirestore->>Firebase: getFirestore(useFirebaseApp("app"))
Firebase-->>useFirestore: Firestore instance
useFirestore-->>Caller: return Firestore
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)src/firestore/index.ts (2)
🔇 Additional comments (2)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit