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:
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?
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
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments