googleapis / googleapis/google-cloud-java

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

Abierto
#13,135 1 comentario 0 reacciones 0 asignados Ver en GitHub
api: firestore priority: p2 type: bug
Lenguaje dominante
Java
Estrellas
2.1k
Forks
1.2k
Merge medio
1 d 23 h
PR fusionados (30 d)
154

Descripción

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
}
}
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.