What's difference between Firebase.firestore
and FirebaseFirestore.getInstance()
?
When do I want to update DB, which one is appropriate for this purpose?
And when I want to check the extracted result value from Firestore.
if I log it, it only prints the object name not result in string value that is contained in the object.
db.collection("users").whereEqualTo("userId", userId?.toInt())
.get()
.addOnSuccessListener {
documents - >
for (document in documents) {
Log.d("결과", documents.toString())
}
}
If I print this, it throws result like below:
com.google.firebase.firestore.QuerySnapshot@b38fd47b
I want to read fields and values of this QuerySnapshot, how can I do this?
share code and error:
var db = Firebase.firestore
val stDocRef = db.collection("users").whereEqualTo("userId", userId?.toInt())
db.runTransaction { transaction ->
transaction.update(stDocRef,"name", "new name")
null
}.addOnSuccessListener { Log.d("결과", "Transaction success!") }