Skip to content

Commit 7a46bd0

Browse files
authored
Merge 468e03c into 8e9aac2
2 parents 8e9aac2 + 468e03c commit 7a46bd0

File tree

7 files changed

+168
-12
lines changed

7 files changed

+168
-12
lines changed

.changeset/hungry-zebras-laugh.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/firestore": minor
3+
---
4+
5+
Expose the MultiDB API for Public Preview. [#7356](https://github.com/firebase/firebase-js-sdk/pull/7356)

common/api-review/firestore-lite.api.md

+9
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,21 @@ export function getFirestore(): Firestore;
218218
// @public
219219
export function getFirestore(app: FirebaseApp): Firestore;
220220

221+
// @beta
222+
export function getFirestore(databaseId: string): Firestore;
223+
224+
// @beta
225+
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
226+
221227
// @public
222228
export function increment(n: number): FieldValue;
223229

224230
// @public
225231
export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore;
226232

233+
// @beta
234+
export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore;
235+
227236
// @public
228237
export function limit(limit: number): QueryLimitConstraint;
229238

common/api-review/firestore.api.md

+6
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,15 @@ export function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>
277277
// @public
278278
export function getFirestore(app: FirebaseApp): Firestore;
279279

280+
// @beta
281+
export function getFirestore(databaseId: string): Firestore;
282+
280283
// @public
281284
export function getFirestore(): Firestore;
282285

286+
// @beta
287+
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
288+
283289
// @public
284290
export function increment(n: number): FieldValue;
285291

docs-devsite/firestore_.md

+55-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ https://github.com/firebase/firebase-js-sdk
1717
| --- | --- |
1818
| <b>function(app...)</b> |
1919
| [getFirestore(app)](./firestore_.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
20+
| [getFirestore(app, databaseId)](./firestore_.md#getfirestore) | <b><i>(BETA)</i></b> Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
2021
| [initializeFirestore(app, settings, databaseId)](./firestore_.md#initializefirestore) | Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore)<!-- -->. If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore)<!-- -->. |
2122
| <b>function(firestore...)</b> |
2223
| [clearIndexedDbPersistence(firestore)](./firestore_.md#clearindexeddbpersistence) | Clears the persistent storage. This includes pending writes and cached documents.<!-- -->Must be called while the [Firestore](./firestore_.firestore.md#firestore_class) instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore) or [getFirestore()](./firestore_.md#getfirestore)<!-- -->)). If the [Firestore](./firestore_.firestore.md#firestore_class) instance is still running, the promise will be rejected with the error code of <code>failed-precondition</code>.<!-- -->Note: <code>clearIndexedDbPersistence()</code> is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. |
@@ -45,6 +46,8 @@ https://github.com/firebase/firebase-js-sdk
4546
| [memoryEagerGarbageCollector()](./firestore_.md#memoryeagergarbagecollector) | Creates an instance of <code>MemoryEagerGarbageCollector</code>. This is also the default garbage collector unless it is explicitly specified otherwise. |
4647
| [persistentMultipleTabManager()](./firestore_.md#persistentmultipletabmanager) | Creates an instance of <code>PersistentMultipleTabManager</code>. |
4748
| [serverTimestamp()](./firestore_.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc) or [updateDoc()](./firestore_lite.md#updatedoc) to include a server-generated timestamp in the written data. |
49+
| <b>function(databaseId...)</b> |
50+
| [getFirestore(databaseId)](./firestore_.md#getfirestore) | <b><i>(BETA)</i></b> Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
4851
| <b>function(elements...)</b> |
4952
| [arrayRemove(elements)](./firestore_.md#arrayremove) | Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. |
5053
| [arrayUnion(elements)](./firestore_.md#arrayunion) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc) or [updateDoc()](./firestore_lite.md#updatedoc) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. |
@@ -226,6 +229,32 @@ export declare function getFirestore(app: FirebaseApp): Firestore;
226229

227230
The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app.
228231

232+
## getFirestore()
233+
234+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
235+
>
236+
237+
Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings.
238+
239+
<b>Signature:</b>
240+
241+
```typescript
242+
export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
243+
```
244+
245+
### Parameters
246+
247+
| Parameter | Type | Description |
248+
| --- | --- | --- |
249+
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. |
250+
| databaseId | string | The name of the database. |
251+
252+
<b>Returns:</b>
253+
254+
[Firestore](./firestore_.firestore.md#firestore_class)
255+
256+
The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app.
257+
229258
## initializeFirestore()
230259

231260
Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore)<!-- -->. If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore)<!-- -->.
@@ -242,7 +271,7 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
242271
| --- | --- | --- |
243272
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the [Firestore](./firestore_.firestore.md#firestore_class) instance will be associated. |
244273
| settings | [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | A settings object to configure the [Firestore](./firestore_.firestore.md#firestore_class) instance. |
245-
| databaseId | string | The name of database. |
274+
| databaseId | string | The name of the database. |
246275

247276
<b>Returns:</b>
248277

@@ -855,6 +884,31 @@ export declare function serverTimestamp(): FieldValue;
855884

856885
[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class)
857886

887+
## getFirestore()
888+
889+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
890+
>
891+
892+
Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings.
893+
894+
<b>Signature:</b>
895+
896+
```typescript
897+
export declare function getFirestore(databaseId: string): Firestore;
898+
```
899+
900+
### Parameters
901+
902+
| Parameter | Type | Description |
903+
| --- | --- | --- |
904+
| databaseId | string | The name of the database. |
905+
906+
<b>Returns:</b>
907+
908+
[Firestore](./firestore_.firestore.md#firestore_class)
909+
910+
The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app.
911+
858912
## arrayRemove()
859913

860914
Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array.

docs-devsite/firestore_lite.md

+82
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ https://github.com/firebase/firebase-js-sdk
1717
| --- | --- |
1818
| <b>function(app...)</b> |
1919
| [getFirestore(app)](./firestore_lite.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
20+
| [getFirestore(app, databaseId)](./firestore_lite.md#getfirestore) | <b><i>(BETA)</i></b> Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
2021
| [initializeFirestore(app, settings)](./firestore_lite.md#initializefirestore) | Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore)<!-- -->. If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore)<!-- -->. |
22+
| [initializeFirestore(app, settings, databaseId)](./firestore_lite.md#initializefirestore) | <b><i>(BETA)</i></b> Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore)<!-- -->. If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore)<!-- -->. |
2123
| <b>function(firestore...)</b> |
2224
| [collection(firestore, path, pathSegments)](./firestore_lite.md#collection) | Gets a <code>CollectionReference</code> instance that refers to the collection at the specified absolute path. |
2325
| [collectionGroup(firestore, collectionId)](./firestore_lite.md#collectiongroup) | Creates and returns a new <code>Query</code> instance that includes all documents in the database that are contained in a collection or subcollection with the given <code>collectionId</code>. |
@@ -31,6 +33,8 @@ https://github.com/firebase/firebase-js-sdk
3133
| [documentId()](./firestore_lite.md#documentid) | Returns a special sentinel <code>FieldPath</code> to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. |
3234
| [getFirestore()](./firestore_lite.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
3335
| [serverTimestamp()](./firestore_lite.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc) or [updateDoc()](./firestore_lite.md#updatedoc) to include a server-generated timestamp in the written data. |
36+
| <b>function(databaseId...)</b> |
37+
| [getFirestore(databaseId)](./firestore_lite.md#getfirestore) | <b><i>(BETA)</i></b> Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings. |
3438
| <b>function(elements...)</b> |
3539
| [arrayRemove(elements)](./firestore_lite.md#arrayremove) | Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. |
3640
| [arrayUnion(elements)](./firestore_lite.md#arrayunion) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc) or [updateDoc()](./firestore_lite.md#updatedoc) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. |
@@ -163,6 +167,32 @@ export declare function getFirestore(app: FirebaseApp): Firestore;
163167

164168
The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app.
165169

170+
## getFirestore()
171+
172+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
173+
>
174+
175+
Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings.
176+
177+
<b>Signature:</b>
178+
179+
```typescript
180+
export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
181+
```
182+
183+
### Parameters
184+
185+
| Parameter | Type | Description |
186+
| --- | --- | --- |
187+
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. |
188+
| databaseId | string | The name of the database. |
189+
190+
<b>Returns:</b>
191+
192+
[Firestore](./firestore_lite.firestore.md#firestore_class)
193+
194+
The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app.
195+
166196
## initializeFirestore()
167197

168198
Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore)<!-- -->. If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore)<!-- -->.
@@ -186,6 +216,33 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Settings
186216

187217
A newly initialized `Firestore` instance.
188218

219+
## initializeFirestore()
220+
221+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
222+
>
223+
224+
Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore)<!-- -->. If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore)<!-- -->.
225+
226+
<b>Signature:</b>
227+
228+
```typescript
229+
export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore;
230+
```
231+
232+
### Parameters
233+
234+
| Parameter | Type | Description |
235+
| --- | --- | --- |
236+
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the <code>Firestore</code> instance will be associated. |
237+
| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the <code>Firestore</code> instance. |
238+
| databaseId | string | The name of the database. |
239+
240+
<b>Returns:</b>
241+
242+
[Firestore](./firestore_lite.firestore.md#firestore_class)
243+
244+
A newly initialized `Firestore` instance.
245+
189246
## collection()
190247

191248
Gets a `CollectionReference` instance that refers to the collection at the specified absolute path.
@@ -424,6 +481,31 @@ export declare function serverTimestamp(): FieldValue;
424481

425482
[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class)
426483

484+
## getFirestore()
485+
486+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
487+
>
488+
489+
Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes a new instance with default settings.
490+
491+
<b>Signature:</b>
492+
493+
```typescript
494+
export declare function getFirestore(databaseId: string): Firestore;
495+
```
496+
497+
### Parameters
498+
499+
| Parameter | Type | Description |
500+
| --- | --- | --- |
501+
| databaseId | string | The name of the database. |
502+
503+
<b>Returns:</b>
504+
505+
[Firestore](./firestore_lite.firestore.md#firestore_class)
506+
507+
The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app.
508+
427509
## arrayRemove()
428510

429511
Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array.

packages/firestore/src/api/database.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class Firestore extends LiteFirestore {
134134
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
135135
* be associated.
136136
* @param settings - A settings object to configure the {@link Firestore} instance.
137-
* @param databaseId - The name of database.
137+
* @param databaseId - The name of the database.
138138
* @returns A newly initialized {@link Firestore} instance.
139139
*/
140140
export function initializeFirestore(
@@ -210,9 +210,9 @@ export function getFirestore(app: FirebaseApp): Firestore;
210210
* default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
211211
* instance with default settings.
212212
*
213-
* @param databaseId - The name of database.
213+
* @param databaseId - The name of the database.
214214
* @returns The {@link Firestore} instance of the provided app.
215-
* @internal
215+
* @beta
216216
*/
217217
export function getFirestore(databaseId: string): Firestore;
218218
/**
@@ -230,9 +230,9 @@ export function getFirestore(): Firestore;
230230
*
231231
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
232232
* instance is associated with.
233-
* @param databaseId - The name of database.
233+
* @param databaseId - The name of the database.
234234
* @returns The {@link Firestore} instance of the provided app.
235-
* @internal
235+
* @beta
236236
*/
237237
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
238238
export function getFirestore(

0 commit comments

Comments
 (0)