Firebase : Questions for TechPrep #8
Riyaz1000
started this conversation in
Interview Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
1. What is Firebase?
2. What is Firebase architecture?
3. Is firebase frontend or backend?
4 . What are the features of Firebase?
5 . What is the difference between Firebase and MongoDB ?
Answer:
6 . What is the push method in firebase?
7 . What is the set() method in firebase?
8 . Which method is used to update the firebase data?
9 . Is Firebase key value?
10. How can we create a unique key and use it to send data in Firebase?
Answer : We can use push() to establish a unique key in the Firebase database, and then add child nodes to that key. When you return to that activity in the future, check to see if the parent node is still present. Save the parent node key and use it to save new child nodes if the node already exists.
@string parentKey;
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("Employee");
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@OverRide
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot != null && dataSnapshot.exists()) {
// parent node exists, get parent node from datasnapshot
parentKey = dataSnapshot.value().toString();
} else {
// parent node doesn't exists, create parent node using push
parentKey = FirebaseDatabase.getInstance().getReference().child("Employee").push().getKey();
}
}
String childKey = FirebaseDatabase.getInstance().getReference("Employee")
.child(parentKey).push().getKey();
10 . Does Firebase support descending sort order?
11 . How do I get particular data from Firebase?
Answer : // Get a reference to your user
final FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference ref = database.getReference("server/path/to/profile");
// Attach a listener to read the data at your profile reference
`ref.addValueEventListener(new ValueEventListener() {
@OverRide
public void onDataChange(DataSnapshot dataSnapshot) {
Profile profile = dataSnapshot.getValue(Profile.class);
System.out.println(profile.getUsername());
}
});`
12 . How to use Firebase Database REST API?
It is necessary to use HTTPS. To keep your data safe, Firebase only responds to encrypted traffic.
For Example:
Get - Read the data
curl 'https://[PROJECT_ID].firebaseio.com/users/john/name.json'
A 200 OK HTTP status code indicates a successful request. The data corresponding with the path in the GET request is provided in the response.
{ "first": "John", "last": "Brook" }
Beta Was this translation helpful? Give feedback.
All reactions