I'm attempting to do a Firebase Transaction, in order to change values in two locations in my Firebase Database, but the MutableData the transaction hands me is null.
Is it forbidden to run a Transaction on the Database root? Do I have to run multiple chained transactions in order to accomplish this?
val ref = FirebaseDatabase
.getInstance()
.getReference("/")
ref.runTransaction(object : Transaction.Handler {
override fun doTransaction(currentData: MutableData): Transaction.Result {
println( currentData) // { key = <none>, value = null }
if (currentData.value == null){
return Transaction.success(currentData)
}
currentData.child("users/{userID}/someVal/").setValue(X)
currentData.child("items/{itemID}/someVal/").setValue(Y)
return Transaction.success(currentData)
}
})