fun quickstart()

in firestore/src/main/kotlin/Quickstart.kt [19:36]


fun quickstart(collectionName: String, documentName: String) {
    // [START firestore_quickstart]
    // Create the client.
    val db = FirestoreOptions.newBuilder()
        .build()
        .service

    // Fetch the document reference and data object.
    val docRef = db.collection(collectionName).document(documentName)
    val data = docRef
        .get() // future
        .get() // snapshot
        .data ?: error("Document $collectionName:$documentName not found") // MutableMap

    // Print the retrieved data.
    data.forEach { (key, value) -> println("$key: $value") }
    // [END firestore_quickstart]
}