Last active
March 1, 2020 23:33
-
-
Save hiranya911/725d11df3ad816f9ff18b262e74b2edb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun addPerson(firstName: String, familyName: String): Task<Void> { | |
val data = hashMapOf( | |
"firstName" to firstName, | |
"familyName" to familyName | |
) | |
return db.collection("people").document() | |
.set(data) | |
} | |
fun getPerson(personId: String) { | |
db.collection("people").document(personId) | |
.get() | |
.addOnSuccessListener { snapshot -> | |
val data = snapshot.data ?: hashMapOf() | |
// Read the 'familyName' field. Old documents call this 'surname'. | |
val familyName = data["familyName"] ?: data["surname"] | |
updateView(familyName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment