-
Notifications
You must be signed in to change notification settings - Fork 36
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
How can I choose a custom database ID instead of the (default) one? #130
Comments
Hey! You can configure it using the options |
@kossnocorp apologies for raising this again, I tried using the schema option like you have suggested, but it didn't work as expected. Below is the logic used in typesaurus to get firestore, when we pass export function firestore(options) {
const appName = options?.server?.app || options?.app;
const app = getApp(appName);
if (options?.server?.preferRest) {
return initializeFirestore(app, {
preferRest: options?.server?.preferRest,
});
} else {
return getFirestore(app);
}
}
export function getFirestore(app: App, databaseId: string): Firestore;
export function getFirestore(
appOrDatabaseId?: App | string,
optionalDatabaseId?: string
): Firestore {
const app: App = typeof appOrDatabaseId === 'object' ? appOrDatabaseId : getApp();
const databaseId =
(typeof appOrDatabaseId === 'string' ? appOrDatabaseId : optionalDatabaseId) || DEFAULT_DATABASE_ID;
const firebaseApp: FirebaseApp = app as FirebaseApp;
const firestoreService = firebaseApp.getOrInitService(
'firestore', (app) => new FirestoreService(app));
return firestoreService.getDatabase(databaseId);
} |
Hey, sorry that it doesn't work for you. Let me reopen the issue, add tests and fix it. |
I had this need myself, just submitted a PR that fixes it @kossnocorp |
@kossnocorp Can we get a bit of love on this issue and get this merged and released? Not being able to select a different DB is a hard blocker for many I'm sure. This feature has been GA in Firestore since February. |
Reopening #126
databaseId is second param to getFirestore, without this it always uses (default) database
typesaurus/src/adapter/admin/firebase.mjs
Line 15 in 7976747
The text was updated successfully, but these errors were encountered: