Skip to content
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

Support for Non Default database access in Firestore #678

Open
inderrapido opened this issue Nov 28, 2024 · 4 comments
Open

Support for Non Default database access in Firestore #678

inderrapido opened this issue Nov 28, 2024 · 4 comments

Comments

@inderrapido
Copy link

Is there any plan to add support for accessing the non-default database in Firestore?

@nbransby
Copy link
Member

So we not already have this?

@inderrapido
Copy link
Author

So we not already have this?

Unfortunately, it’s not available. We’re currently limited to connecting only to the default database.

@nbransby
Copy link
Member

please use this template

@sjaindl
Copy link

sjaindl commented Dec 22, 2024

I have the same issue. Using a non-default database was possible until version 1.13.0, by using:

commonMain:

expect fun getFirebaseFirestore(): FirebaseFirestore

androidMain:

import com.google.firebase.Firebase
import com.google.firebase.firestore.firestore
import dev.gitlive.firebase.firestore.FirebaseFirestore

actual fun getFirebaseFirestore(): FirebaseFirestore {
    return FirebaseFirestore(native = Firebase.firestore(database = "prod-db"))
}

iOSMain:

import cocoapods.FirebaseFirestoreInternal.FIRFirestore
import dev.gitlive.firebase.firestore.FirebaseFirestore
import kotlinx.cinterop.ExperimentalForeignApi

@OptIn(ExperimentalForeignApi::class)
actual fun getFirebaseFirestore(): FirebaseFirestore {
    return FirebaseFirestore(FIRFirestore.firestoreForDatabase(database = "prod-db"))
}

However, with version 2.0.0 FirebaseFirestore was declared as internal, which leads to the error:
Cannot access 'constructor(native: FirebaseFirestore): FirebaseFirestore': it is internal in 'dev/gitlive/firebase/firestore/FirebaseFirestore'.

@nbransby Can it be declared as public again?
Or is there an alternate new way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants