From 2cd3d58d07c084333caccb882c9259a6d35ae7cb Mon Sep 17 00:00:00 2001 From: Tom Andersen Date: Fri, 9 Jun 2023 11:08:57 -0400 Subject: [PATCH 1/2] Expose MultiDB within Firestore --- src/firestore/index.ts | 90 +++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/src/firestore/index.ts b/src/firestore/index.ts index d1736af570..eafcc5367b 100644 --- a/src/firestore/index.ts +++ b/src/firestore/index.ts @@ -75,58 +75,72 @@ export { export { FirestoreSettings }; /** - * Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * Gets the default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} * service for the default app. * - * `getFirestore()` can be called with no arguments to access the default - * app's `Firestore` service or as `getFirestore(app)` to access the - * `Firestore` service associated with a specific app. - * * @example * ```javascript - * // Get the Firestore service for the default app + * // Get the default Firestore service for the default app * const defaultFirestore = getFirestore(); * ``` * @returns The default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} - * service if no app is provided or the `Firestore` service associated with the - * provided app. + * service for the default app. */ export function getFirestore(): Firestore; /** - * Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * Gets the default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} * service for the given app. * - * `getFirestore()` can be called with no arguments to access the default - * app's `Firestore` service or as `getFirestore(app)` to access the - * `Firestore` service associated with a specific app. - * * @example * ```javascript - * // Get the Firestore service for a specific app + * // Get the default Firestore service for a specific app * const otherFirestore = getFirestore(app); * ``` * - * @param App - which `Firestore` service to - * return. If not provided, the default `Firestore` service will be returned. + * @param app - which `Firestore` service to return. * * @returns The default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} - * service if no app is provided or the `Firestore` service associated with the - * provided app. + * service associated with the provided app. */ export function getFirestore(app: App): Firestore; /** - * @param databaseId - * @internal + * Gets the named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * service for the default app. + * + * @example + * ```javascript + * // Get the Firestore service for a named database and default app + * const otherFirestore = getFirestore('otherDb'); + * ``` + * + * @param databaseId - name of database to return. + * + * @returns The named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * service for the default app. + * @beta */ export function getFirestore(databaseId: string): Firestore; /** - * @param app - * @param databaseId - * @internal + * Gets the named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * service for the given app. + * + * @example + * ```javascript + * // Get the Firestore service for a named database and specific app. + * const otherFirestore = getFirestore('otherDb'); + * ``` + * + * @param app - which `Firestore` service to return. + * + * @param databaseId - name of database to return. + * + * @returns The named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * service associated with the provided app. + * @beta */ export function getFirestore(app: App, databaseId: string): Firestore; @@ -144,7 +158,7 @@ export function getFirestore( } /** - * Gets the {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * Gets the default {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} * service for the given app, passing extra parameters to its constructor. * * @example @@ -153,20 +167,32 @@ export function getFirestore( * const otherFirestore = initializeFirestore(app, {preferRest: true}); * ``` * - * @param App - which `Firestore` service to - * return. If not provided, the default `Firestore` service will be returned. - * + * @param app - which `Firestore` service to return. + * * @param settings - Settings object to be passed to the constructor. * - * @returns The `Firestore` service associated with the provided app and settings. + * @returns The default `Firestore` service associated with the provided app and settings. */ export function initializeFirestore(app: App, settings?: FirestoreSettings): Firestore; /** - * @param app - * @param settings - * @param databaseId - * @internal + * Gets the named {@link https://googleapis.dev/nodejs/firestore/latest/Firestore.html | Firestore} + * service for the given app, passing extra parameters to its constructor. + * + * @example + * ```javascript + * // Get the Firestore service for a specific app, require HTTP/1.1 REST transport + * const otherFirestore = initializeFirestore(app, {preferRest: true}, 'otherDb'); + * ``` + * + * @param app - which `Firestore` service to return. + * + * @param settings - Settings object to be passed to the constructor. + * + * @param databaseId - name of database to return. + * + * @returns The named `Firestore` service associated with the provided app and settings. + * @beta */ export function initializeFirestore( app: App, From d5a1f7283eaee3aa3ed218e89e2033880ea9bb50 Mon Sep 17 00:00:00 2001 From: Tom Andersen Date: Fri, 9 Jun 2023 11:21:47 -0400 Subject: [PATCH 2/2] Expose MultiDB within Firestore --- etc/firebase-admin.firestore.api.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/etc/firebase-admin.firestore.api.md b/etc/firebase-admin.firestore.api.md index fd20e4ea79..960e320daf 100644 --- a/etc/firebase-admin.firestore.api.md +++ b/etc/firebase-admin.firestore.api.md @@ -100,11 +100,20 @@ export function getFirestore(): Firestore; // @public export function getFirestore(app: App): Firestore; +// @beta +export function getFirestore(databaseId: string): Firestore; + +// @beta +export function getFirestore(app: App, databaseId: string): Firestore; + export { GrpcStatus } // @public export function initializeFirestore(app: App, settings?: FirestoreSettings): Firestore; +// @beta +export function initializeFirestore(app: App, settings: FirestoreSettings, databaseId: string): Firestore; + export { NestedUpdateFields } export { OrderByDirection }