ndd*_*ong 4 ios firebase swift firebase-realtime-database
我试图获取Firebase中嵌套节点的键,我不知道如何做到这一点.
例如,在这种情况下:
我怎么知道2,3,4存在于1?
我想在firebase中单独列出一个值.但有更聪明的方法吗?是否有更有效的方法来获取Firebase中所有嵌套节点的密钥?
在Android中
允许访问此快照的所有直接子项.可以在native for循环中使用:
for (DataSnapshot child : parent.getChildren()) {
//Here you can access the child.getKey()
}
Run Code Online (Sandbox Code Playgroud)
在iOS中
斯威夫特3:
for (child in snapshot.children) {
//Here you can access child.key
}
Run Code Online (Sandbox Code Playgroud)
斯威夫特4:
snapshot.children.forEach({ (child) in
<#code#>
})
Run Code Online (Sandbox Code Playgroud)
在网上
snapshot.forEach(function(childSnapshot) {
//Here you can access childSnapshot.key
});
Run Code Online (Sandbox Code Playgroud)
您可以将它放在不同的列表或相同的路径中,重要的是要记住在调用事件时您实际检索的数据量.您将如何查询该信息...这就是为什么在NoSQL中建议保持平面节点的原因
| 归档时间: |
|
| 查看次数: |
7962 次 |
| 最近记录: |