Skip to content

Deprecate getFirestore and initializeFirestore overloads that do not accept databaseId #8985

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ export class Firestore extends LiteFirestore {
}
}

/**
* Initializes a new instance of {@link Firestore} with the provided settings.
* Can only be called before any other function, including
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
* equivalent to calling {@link (getFirestore:1)}.
*
* @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.
* @returns A newly initialized {@link Firestore} instance.
* @deprecated This function assumes the database name is `(default)`. For new
* databases, the database name is specified during creation, and can no longer
* be assumed to be '(default)' by the SDK. Please use the function overload
* that accepts `databaseId`, {@link initializeFirestore:2}.
*/
export function initializeFirestore(
app: FirebaseApp,
settings: FirestoreSettings
): Firestore;

/**
* Initializes a new instance of {@link Firestore} with the provided settings.
* Can only be called before any other function, including
Expand All @@ -142,6 +162,11 @@ export class Firestore extends LiteFirestore {
* @param databaseId - The name of the database.
* @returns A newly initialized {@link Firestore} instance.
*/
export function initializeFirestore(
app: FirebaseApp,
settings: FirestoreSettings,
databaseId: string
): Firestore;
export function initializeFirestore(
app: FirebaseApp,
settings: FirestoreSettings,
Expand Down Expand Up @@ -206,6 +231,11 @@ export function initializeFirestore(
* instance with default settings.
*
* @returns The default {@link Firestore} instance of the default app.
*
* @deprecated This function assumes the database name is `(default)`. For new
* databases, the database name is specified during creation, and can no longer
* be assumed to be '(default)' by the SDK. Please use the function overload
* that accepts `databaseId`, {@link getFirestore:3}.
*/
export function getFirestore(): Firestore;
/**
Expand All @@ -216,6 +246,11 @@ export function getFirestore(): Firestore;
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
* instance is associated with.
* @returns The default {@link Firestore} instance of the provided app.
*
* @deprecated This function assumes the database name is `(default)`. For new
* databases, the database name is specified during creation, and can no longer
* be assumed to be '(default)' by the SDK. Please use the function overload
* that accepts `databaseId`, {@link getFirestore:4}.
*/
export function getFirestore(app: FirebaseApp): Firestore;
/**
Expand All @@ -225,7 +260,6 @@ export function getFirestore(app: FirebaseApp): Firestore;
*
* @param databaseId - The name of the database.
* @returns The named {@link Firestore} instance of the default app.
* @beta
*/
export function getFirestore(databaseId: string): Firestore;
/**
Expand All @@ -237,7 +271,6 @@ export function getFirestore(databaseId: string): Firestore;
* instance is associated with.
* @param databaseId - The name of the database.
* @returns The named {@link Firestore} instance of the provided app.
* @beta
*/
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
export function getFirestore(
Expand Down
16 changes: 15 additions & 1 deletion packages/firestore/src/lite-api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ export class Firestore implements FirestoreService {
* be associated.
* @param settings - A settings object to configure the `Firestore` instance.
* @returns A newly initialized `Firestore` instance.
* @deprecated This function assumes the database name is `(default)`. For new
* databases, the database name is specified during creation, and can no longer
* be assumed to be '(default)' by the SDK. Please use the function overload
* that accepts `databaseId`, {@link initializeFirestore:2}.
*/
export function initializeFirestore(
app: FirebaseApp,
Expand All @@ -217,7 +221,7 @@ export function initializeFirestore(
export function initializeFirestore(
app: FirebaseApp,
settings: FirestoreSettings,
databaseId?: string
databaseId: string
): Firestore;
export function initializeFirestore(
app: FirebaseApp,
Expand All @@ -243,6 +247,11 @@ export function initializeFirestore(
}

/**
* @deprecated This function assumes the database name is `(default)`. For new
* databases, the database name is specified during creation, and can no longer
* be assumed to be '(default)' by the SDK. Please use the function overload
* that accepts `databaseId`, {@link getFirestore:3}.
*
* Returns the existing default {@link Firestore} instance that is associated with the
* default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
* instance with default settings.
Expand All @@ -251,6 +260,11 @@ export function initializeFirestore(
*/
export function getFirestore(): Firestore;
/**
* @deprecated This function assumes the database name is `(default)`. For new
* databases, the database name is specified during creation, and can no longer
* be assumed to be '(default)' by the SDK. Please use the function overload
* that accepts `databaseId`, {@link getFirestore:4}.
*
* Returns the existing default {@link Firestore} instance that is associated with the
* provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
* instance with default settings.
Expand Down
Loading