[英]How do I fetch data from firebase realtime database which are children to a random key - using react native?
[英]How to get random pushed key from firebase realtime database
我即将按日期(时间戳)和以下图像中的 videoId 值删除孩子 -MAkugTU_85UTvn4g9Hn
我试过下面的代码只返回名为 oUi3NI9SdcbCC6v5EmygDNV4lrg1 的父级,而不是随机推送的键,任何建议都将不胜感激。 谢谢
const uid = firebase.auth().currentUser.uid;
const ref = firebase.database().ref('posts').child(uid);
ref.orderByChild('date').equalTo(date).once("value",snapshot => {
console.log(snapshot.key) // oUi3NI9SdcbCC6v5EmygDNV4lrg1
});
const ref = firebase.database().ref('posts').child(uid);
ref.orderByChild('date').equalTo(date).once("value",snapshot => {
console.log(snapshot.key) // key of parent
snapshot.forEach((childSnapshot) => {
console.log(childSnapshot.key) //here you will get key of each child
}
});
然后通过使用子键,你可以做任何你想做的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.