Skip to content

Commit 8c643da

Browse files
authored
Expose MultiDB within Firestore (#2209)
* Expose MultiDB within Firestore * Expose MultiDB within Firestore
1 parent 625e8d7 commit 8c643da

File tree

2 files changed

+67
-32
lines changed

2 files changed

+67
-32
lines changed

etc/firebase-admin.firestore.api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,20 @@ export function getFirestore(): Firestore;
100100
// @public
101101
export function getFirestore(app: App): Firestore;
102102

103+
// @beta
104+
export function getFirestore(databaseId: string): Firestore;
105+
106+
// @beta
107+
export function getFirestore(app: App, databaseId: string): Firestore;
108+
103109
export { GrpcStatus }
104110

105111
// @public
106112
export function initializeFirestore(app: App, settings?: FirestoreSettings): Firestore;
107113

114+
// @beta
115+
export function initializeFirestore(app: App, settings: FirestoreSettings, databaseId: string): Firestore;
116+
108117
export { NestedUpdateFields }
109118

110119
export { OrderByDirection }

src/firestore/index.ts

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,58 +75,72 @@ export {
7575
export { FirestoreSettings };
7676

7777
/**
78-
* Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
78+
* Gets the default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
7979
* service for the default app.
8080
*
81-
* `getFirestore()` can be called with no arguments to access the default
82-
* app's `Firestore` service or as `getFirestore(app)` to access the
83-
* `Firestore` service associated with a specific app.
84-
*
8581
* @example
8682
* ```javascript
87-
* // Get the Firestore service for the default app
83+
* // Get the default Firestore service for the default app
8884
* const defaultFirestore = getFirestore();
8985
* ```
9086
9187
* @returns The default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
92-
* service if no app is provided or the `Firestore` service associated with the
93-
* provided app.
88+
* service for the default app.
9489
*/
9590
export function getFirestore(): Firestore;
9691

9792
/**
98-
* Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
93+
* Gets the default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
9994
* service for the given app.
10095
*
101-
* `getFirestore()` can be called with no arguments to access the default
102-
* app's `Firestore` service or as `getFirestore(app)` to access the
103-
* `Firestore` service associated with a specific app.
104-
*
10596
* @example
10697
* ```javascript
107-
* // Get the Firestore service for a specific app
98+
* // Get the default Firestore service for a specific app
10899
* const otherFirestore = getFirestore(app);
109100
* ```
110101
*
111-
* @param App - which `Firestore` service to
112-
* return. If not provided, the default `Firestore` service will be returned.
102+
* @param app - which `Firestore` service to return.
113103
*
114104
* @returns The default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
115-
* service if no app is provided or the `Firestore` service associated with the
116-
* provided app.
105+
* service associated with the provided app.
117106
*/
118107
export function getFirestore(app: App): Firestore;
119108

120109
/**
121-
* @param databaseId
122-
* @internal
110+
* Gets the named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
111+
* service for the default app.
112+
*
113+
* @example
114+
* ```javascript
115+
* // Get the Firestore service for a named database and default app
116+
* const otherFirestore = getFirestore('otherDb');
117+
* ```
118+
*
119+
* @param databaseId - name of database to return.
120+
*
121+
* @returns The named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
122+
* service for the default app.
123+
* @beta
123124
*/
124125
export function getFirestore(databaseId: string): Firestore;
125126

126127
/**
127-
* @param app
128-
* @param databaseId
129-
* @internal
128+
* Gets the named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
129+
* service for the given app.
130+
*
131+
* @example
132+
* ```javascript
133+
* // Get the Firestore service for a named database and specific app.
134+
* const otherFirestore = getFirestore('otherDb');
135+
* ```
136+
*
137+
* @param app - which `Firestore` service to return.
138+
*
139+
* @param databaseId - name of database to return.
140+
*
141+
* @returns The named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
142+
* service associated with the provided app.
143+
* @beta
130144
*/
131145
export function getFirestore(app: App, databaseId: string): Firestore;
132146

@@ -144,7 +158,7 @@ export function getFirestore(
144158
}
145159

146160
/**
147-
* Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
161+
* Gets the default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
148162
* service for the given app, passing extra parameters to its constructor.
149163
*
150164
* @example
@@ -153,20 +167,32 @@ export function getFirestore(
153167
* const otherFirestore = initializeFirestore(app, {preferRest: true});
154168
* ```
155169
*
156-
* @param App - which `Firestore` service to
157-
* return. If not provided, the default `Firestore` service will be returned.
158-
*
170+
* @param app - which `Firestore` service to return.
171+
*
159172
* @param settings - Settings object to be passed to the constructor.
160173
*
161-
* @returns The `Firestore` service associated with the provided app and settings.
174+
* @returns The default `Firestore` service associated with the provided app and settings.
162175
*/
163176
export function initializeFirestore(app: App, settings?: FirestoreSettings): Firestore;
164177

165178
/**
166-
* @param app
167-
* @param settings
168-
* @param databaseId
169-
* @internal
179+
* Gets the named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore}
180+
* service for the given app, passing extra parameters to its constructor.
181+
*
182+
* @example
183+
* ```javascript
184+
* // Get the Firestore service for a specific app, require HTTP/1.1 REST transport
185+
* const otherFirestore = initializeFirestore(app, {preferRest: true}, 'otherDb');
186+
* ```
187+
*
188+
* @param app - which `Firestore` service to return.
189+
*
190+
* @param settings - Settings object to be passed to the constructor.
191+
*
192+
* @param databaseId - name of database to return.
193+
*
194+
* @returns The named `Firestore` service associated with the provided app and settings.
195+
* @beta
170196
*/
171197
export function initializeFirestore(
172198
app: App,

0 commit comments

Comments
 (0)