Support for Non Default database access in Firestore
Is there any plan to add support for accessing the non-default database in Firestore?
So we not already have this?
So we not already have this?
Unfortunately, it’s not available. We’re currently limited to connecting only to the default database.
please use this template
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?
Hi @nbransby i too facing this issue.
Just tried updating and ran into this issue as well. I was employing the same solution as @sjaindl to create a named database and now I can't and the SDK doesn't provide a way to do it (AFAICT).
Looks like there's a PR open to solve this but it's still open.
https://github.com/GitLiveApp/firebase-kotlin-sdk/pull/698
Any word on if this PR will merge and when it'll be available?