googleapis / googleapis/google-cloud-java

[java-firestore] [Emulator] Does this library work with the firebase firestore emulator?

Đang mở
#13,135 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
api: firestore priority: p2 type: bug
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

I've been trying to get this library to work with the firestore emulator, and I actually thought for a while that it was working as requests succeed when I write and a project id hasn't been set. The requests aren't actually being saved to the database though. When I look at the emulator database viewer, there is no data.

#### Environment details

2. OS type and version: Mac Big Sur
3. Java version: Java 11
4. firestore version(s): Latest

#### Steps to reproduce

1. Setup Firestore in java code
2. Write data to firestore
3. Requests succeed
4. Try and read data
5. Data doesn't exist

If I set a project id, I get exceptions with clear failures.

#### Code example

```Kotlin
object FirestoreProvider {
const val ENV_FIRESTORE_EMULATOR_HOST = "FIRESTORE_EMULATOR_HOST"
const val ENV_FIRESTORE_DATABASE_ID = "FIRESTORE_DATABASE_ID"

fun create(): Firestore {
val firestoreHost = System.getenv().getOrDefault(ENV_FIRESTORE_EMULATOR_HOST, "localhost:9102")
val isEmulator = firestoreHost.contains("localhost")

println("Using $firestoreHost for the Firestore host.")
println("It is ${if (isEmulator) "" else "not "}being configured as an emulator")

var builder = FirestoreOptions.newBuilder()

if (isEmulator) {
builder = builder
.setEmulatorHost(firestoreHost)
.setCredentials(FirestoreOptions.EmulatorCredentials())
}

return builder.build().service
}
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.