I've recently begun using the FirebaseDatabase library on Android Studio. So, I've read that when you update/modify multiple locations on your Firebase Database, in case any error occurs and to make sure that data isn't modified in some locations and not modified in other, transactions are used.
Transactions in JavaScript have been covered thoroughly and proper documentation has been provided. But, the documentation for the Android Studio library isn't very clear. The links are link1 and link2
What is Mutable data and what value does it hold? Right now, this is how I update or modify the data on my database. I need to update values at nodes posts and user
HashMap<String, Object> hm = new HashMap<>();
hm.put("/users/"+key+"/name/","New Name");
hm.put("/posts/"+key+"/number_of_posts/", 2);
FirebaseDatabase.getInstance().getReference().updateChildren(hm, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
if(databaseError == null)
Log.d(TAG, "TASK WAS SUCCESSFULLY COMPLETED");
else
Log.d(TAG, "SOMETHING WENT WRONG");
}
});
I know this is the wrong way to do this, so an explanation or a link to a tutorial to do this would be really helpful.