I am trying to get the keys of the nested nodes in Firebase and I am not sure how to do this.
For example in this case:
example
How do I know that 2,3,4 exist within 1?
I am thinking of putting a values in a list seperately in firebase. But is there a smarter way of doing this? Is there a more efficient way of getting the keys of all the nested nodes in Firebase?
Firebase automatically creates API keys for your project when you do any of the following: Create a Firebase project > Browser key auto-created. Create a Firebase Apple App > iOS key auto-created. Create a Firebase Android App > Android key auto-created.
A simultaneous connection is equivalent to one mobile device, browser tab, or server app connected to the database. This isn't the same as the total number of users of your app, because your users don't all connect at once.
Using set() overwrites data at the specified location, including any child nodes.
This is because Firebase does not support Arrays directly, but it creates a list of objects with integers as key names.
In Android
Gives access to all of the immediate children of this snapshot. Can be used in native for loops:
for (DataSnapshot child : parent.getChildren()) {
//Here you can access the child.getKey()
}
In iOS
Swift 3:
for (child in snapshot.children) {
//Here you can access child.key
}
Swift 4:
snapshot.children.forEach({ (child) in
<#code#>
})
In Web
snapshot.forEach(function(childSnapshot) {
//Here you can access childSnapshot.key
});
You can put it in a different list or in the same path, the important thing is to keep in mind how much data you are really retrieving when calling an event. And how are you going to query that information... that is why it is recommended in NoSQL to keep flat nodes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With