read data on child firebase code example

Example 1: unity get data from firebase

// Perform the steps at the following link to setup Firebase
// for your Unity project:
https://firebase.google.com/docs/unity/setup

// To connect to the databse in a script, use the following
// two lines:
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://YOURPROJECTNAME.firebaseio.com/");
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

// To get a data snapshot and take action with it:
FirebaseDatabase.DefaultInstance.GetReference("DATABASENAME").GetValueAsync().ContinueWith(task => {
	if (task.IsFaulted)
	{
		// Failure
	}
	else if (task.IsCompleted)
	{
		DataSnapshot snapshot = task.Result;
		// Success
	}
});

Example 2: how to push multiple data to different parents in a single request in firebase

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
// Generate a new push ID for the new post
var newPostRef = ref.child("posts").push();
var newPostKey = newPostRef.key();
// Create the data we want to update
var updatedUserData = {};
updatedUserData["user/posts/" + newPostKey] = true;
updatedUserData["posts/" + newPostKey] = {
  title: "New Post",
  content: "Here is my new post!"
};
// Do a deep-path update
ref.update(updatedUserData, function(error) {
  if (error) {
    console.log("Error updating data:", error);
  }
});