Skip to content

Commit a34563e

Browse files
committed
Deprecate getFirestore and initializeFirestore overloads that do not accept databaseId
1 parent ea1f913 commit a34563e

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

packages/firestore/src/api/database.ts

+35-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ export class Firestore extends LiteFirestore {
130130
}
131131
}
132132

133+
/**
134+
* Initializes a new instance of {@link Firestore} with the provided settings.
135+
* Can only be called before any other function, including
136+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
137+
* equivalent to calling {@link (getFirestore:1)}.
138+
*
139+
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
140+
* be associated.
141+
* @param settings - A settings object to configure the {@link Firestore} instance.
142+
* @returns A newly initialized {@link Firestore} instance.
143+
* @deprecated This function assumes the database name is `(default)`. For new
144+
* databases, the database name is specified during creation, and can no longer
145+
* be assumed to be '(default)' by the SDK. Please use the function overload
146+
* that accepts `databaseId`, {@link initializeFirestore:2}.
147+
*/
148+
export function initializeFirestore(
149+
app: FirebaseApp,
150+
settings: FirestoreSettings
151+
): Firestore;
152+
133153
/**
134154
* Initializes a new instance of {@link Firestore} with the provided settings.
135155
* Can only be called before any other function, including
@@ -142,6 +162,11 @@ export class Firestore extends LiteFirestore {
142162
* @param databaseId - The name of the database.
143163
* @returns A newly initialized {@link Firestore} instance.
144164
*/
165+
export function initializeFirestore(
166+
app: FirebaseApp,
167+
settings: FirestoreSettings,
168+
databaseId: string
169+
): Firestore;
145170
export function initializeFirestore(
146171
app: FirebaseApp,
147172
settings: FirestoreSettings,
@@ -206,6 +231,11 @@ export function initializeFirestore(
206231
* instance with default settings.
207232
*
208233
* @returns The default {@link Firestore} instance of the default app.
234+
*
235+
* @deprecated This function assumes the database name is `(default)`. For new
236+
* databases, the database name is specified during creation, and can no longer
237+
* be assumed to be '(default)' by the SDK. Please use the function overload
238+
* that accepts `databaseId`, {@link getFirestore:3}.
209239
*/
210240
export function getFirestore(): Firestore;
211241
/**
@@ -216,6 +246,11 @@ export function getFirestore(): Firestore;
216246
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
217247
* instance is associated with.
218248
* @returns The default {@link Firestore} instance of the provided app.
249+
*
250+
* @deprecated This function assumes the database name is `(default)`. For new
251+
* databases, the database name is specified during creation, and can no longer
252+
* be assumed to be '(default)' by the SDK. Please use the function overload
253+
* that accepts `databaseId`, {@link getFirestore:4}.
219254
*/
220255
export function getFirestore(app: FirebaseApp): Firestore;
221256
/**
@@ -225,7 +260,6 @@ export function getFirestore(app: FirebaseApp): Firestore;
225260
*
226261
* @param databaseId - The name of the database.
227262
* @returns The named {@link Firestore} instance of the default app.
228-
* @beta
229263
*/
230264
export function getFirestore(databaseId: string): Firestore;
231265
/**
@@ -237,7 +271,6 @@ export function getFirestore(databaseId: string): Firestore;
237271
* instance is associated with.
238272
* @param databaseId - The name of the database.
239273
* @returns The named {@link Firestore} instance of the provided app.
240-
* @beta
241274
*/
242275
export function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
243276
export function getFirestore(

packages/firestore/src/lite-api/database.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ export class Firestore implements FirestoreService {
196196
* be associated.
197197
* @param settings - A settings object to configure the `Firestore` instance.
198198
* @returns A newly initialized `Firestore` instance.
199+
* @deprecated This function assumes the database name is `(default)`. For new
200+
* databases, the database name is specified during creation, and can no longer
201+
* be assumed to be '(default)' by the SDK. Please use the function overload
202+
* that accepts `databaseId`, {@link initializeFirestore:2}.
199203
*/
200204
export function initializeFirestore(
201205
app: FirebaseApp,
@@ -217,7 +221,7 @@ export function initializeFirestore(
217221
export function initializeFirestore(
218222
app: FirebaseApp,
219223
settings: FirestoreSettings,
220-
databaseId?: string
224+
databaseId: string
221225
): Firestore;
222226
export function initializeFirestore(
223227
app: FirebaseApp,
@@ -243,6 +247,11 @@ export function initializeFirestore(
243247
}
244248

245249
/**
250+
* @deprecated This function assumes the database name is `(default)`. For new
251+
* databases, the database name is specified during creation, and can no longer
252+
* be assumed to be '(default)' by the SDK. Please use the function overload
253+
* that accepts `databaseId`, {@link getFirestore:3}.
254+
*
246255
* Returns the existing default {@link Firestore} instance that is associated with the
247256
* default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
248257
* instance with default settings.
@@ -251,6 +260,11 @@ export function initializeFirestore(
251260
*/
252261
export function getFirestore(): Firestore;
253262
/**
263+
* @deprecated This function assumes the database name is `(default)`. For new
264+
* databases, the database name is specified during creation, and can no longer
265+
* be assumed to be '(default)' by the SDK. Please use the function overload
266+
* that accepts `databaseId`, {@link getFirestore:4}.
267+
*
254268
* Returns the existing default {@link Firestore} instance that is associated with the
255269
* provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
256270
* instance with default settings.

0 commit comments

Comments
 (0)