Skip to content

Commit

Permalink
Expose MultiDB API for Public Preview (#7356)
Browse files Browse the repository at this point in the history
* Expose MultiDB API for Public Preview

* Add CHANGELOG

* Update API reports

* Expose MultiDB API for Public Preview

* Docgen

* Fix text

---------

Co-authored-by: DellaBitta <DellaBitta@users.noreply.github.com>
  • Loading branch information
tom-andersen and DellaBitta authored Jun 16, 2023
1 parent 8e9aac2 commit 59c7b58
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-zebras-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": minor
---

Expose the MultiDB API for Public Preview. [#7356](https://github.com/firebase/firebase-js-sdk/pull/7356)
9 changes: 9 additions & 0 deletions common/api-review/firestore-lite.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,21 @@ export function getFirestore(): Firestore;
// @public
export function getFirestore(app: FirebaseApp): Firestore;

// @beta
export function getFirestore(databaseId: string): Firestore;

// @beta
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;

// @public
export function increment(n: number): FieldValue;

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

// @beta
export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore;

// @public
export function limit(limit: number): QueryLimitConstraint;

Expand Down
6 changes: 6 additions & 0 deletions common/api-review/firestore.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,15 @@ export function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>
// @public
export function getFirestore(app: FirebaseApp): Firestore;

// @beta
export function getFirestore(databaseId: string): Firestore;

// @public
export function getFirestore(): Firestore;

// @beta
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;

// @public
export function increment(n: number): FieldValue;

Expand Down
56 changes: 55 additions & 1 deletion docs-devsite/firestore_.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ https://github.com/firebase/firebase-js-sdk
| --- | --- |
| <b>function(app...)</b> |
| [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. |
| [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. |
| [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)<!-- -->. |
| <b>function(firestore...)</b> |
| [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. |
Expand Down Expand Up @@ -45,6 +46,8 @@ https://github.com/firebase/firebase-js-sdk
| [memoryEagerGarbageCollector()](./firestore_.md#memoryeagergarbagecollector) | Creates an instance of <code>MemoryEagerGarbageCollector</code>. This is also the default garbage collector unless it is explicitly specified otherwise. |
| [persistentMultipleTabManager()](./firestore_.md#persistentmultipletabmanager) | Creates an instance of <code>PersistentMultipleTabManager</code>. |
| [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. |
| <b>function(databaseId...)</b> |
| [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. |
| <b>function(elements...)</b> |
| [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. |
| [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. |
Expand Down Expand Up @@ -226,6 +229,32 @@ export declare function getFirestore(app: FirebaseApp): Firestore;

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

## getFirestore()

> 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.
>
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.

<b>Signature:</b>

```typescript
export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| 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. |
| databaseId | string | The name of the database. |

<b>Returns:</b>

[Firestore](./firestore_.firestore.md#firestore_class)

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

## 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)<!-- -->.
Expand All @@ -242,7 +271,7 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
| --- | --- | --- |
| 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. |
| settings | [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | A settings object to configure the [Firestore](./firestore_.firestore.md#firestore_class) instance. |
| databaseId | string | The name of database. |
| databaseId | string | The name of the database. |

<b>Returns:</b>

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

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

## getFirestore()

> 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.
>
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.

<b>Signature:</b>

```typescript
export declare function getFirestore(databaseId: string): Firestore;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| databaseId | string | The name of the database. |

<b>Returns:</b>

[Firestore](./firestore_.firestore.md#firestore_class)

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

## 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.
Expand Down
82 changes: 82 additions & 0 deletions docs-devsite/firestore_lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ https://github.com/firebase/firebase-js-sdk
| --- | --- |
| <b>function(app...)</b> |
| [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. |
| [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. |
| [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)<!-- -->. |
| [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)<!-- -->. |
| <b>function(firestore...)</b> |
| [collection(firestore, path, pathSegments)](./firestore_lite.md#collection) | Gets a <code>CollectionReference</code> instance that refers to the collection at the specified absolute path. |
| [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>. |
Expand All @@ -31,6 +33,8 @@ https://github.com/firebase/firebase-js-sdk
| [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. |
| [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. |
| [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. |
| <b>function(databaseId...)</b> |
| [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. |
| <b>function(elements...)</b> |
| [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. |
| [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. |
Expand Down Expand Up @@ -163,6 +167,32 @@ export declare function getFirestore(app: FirebaseApp): Firestore;

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

## getFirestore()

> 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.
>
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.

<b>Signature:</b>

```typescript
export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| 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. |
| databaseId | string | The name of the database. |

<b>Returns:</b>

[Firestore](./firestore_lite.firestore.md#firestore_class)

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

## 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)<!-- -->.
Expand All @@ -186,6 +216,33 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Settings

A newly initialized `Firestore` instance.

## initializeFirestore()

> 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.
>
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)<!-- -->.

<b>Signature:</b>

```typescript
export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the <code>Firestore</code> instance will be associated. |
| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the <code>Firestore</code> instance. |
| databaseId | string | The name of the database. |

<b>Returns:</b>

[Firestore](./firestore_lite.firestore.md#firestore_class)

A newly initialized `Firestore` instance.

## collection()

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

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

## getFirestore()

> 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.
>
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.

<b>Signature:</b>

```typescript
export declare function getFirestore(databaseId: string): Firestore;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| databaseId | string | The name of the database. |

<b>Returns:</b>

[Firestore](./firestore_lite.firestore.md#firestore_class)

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

## 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.
Expand Down
10 changes: 5 additions & 5 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Firestore extends LiteFirestore {
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
* be associated.
* @param settings - A settings object to configure the {@link Firestore} instance.
* @param databaseId - The name of database.
* @param databaseId - The name of the database.
* @returns A newly initialized {@link Firestore} instance.
*/
export function initializeFirestore(
Expand Down Expand Up @@ -210,9 +210,9 @@ export function getFirestore(app: FirebaseApp): Firestore;
* default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
* instance with default settings.
*
* @param databaseId - The name of database.
* @param databaseId - The name of the database.
* @returns The {@link Firestore} instance of the provided app.
* @internal
* @beta
*/
export function getFirestore(databaseId: string): Firestore;
/**
Expand All @@ -230,9 +230,9 @@ export function getFirestore(): Firestore;
*
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
* instance is associated with.
* @param databaseId - The name of database.
* @param databaseId - The name of the database.
* @returns The {@link Firestore} instance of the provided app.
* @internal
* @beta
*/
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
export function getFirestore(
Expand Down
Loading

0 comments on commit 59c7b58

Please sign in to comment.