[英]how to check if data is already in html table using firebase real time database?
[英]How to if check data in real-time-db FIREBASE
我想检查/比较一下这个数据中是否有值:
例:
const uid = '35nv594aotgcv'
#check if uid is inside
firebase
.database()
.ref('followers/2mvouwB0E0aEN5MnAhOLWaHiu6b2')
.once("value", snapshot => {
if (snapshot.exists()) {
const data = snapshot.val(); // data are the other two uid's in the image above
}
});
那么如何检查const uid = '35nv594aotgcv'
是否在快照数据中?
或者如果我有一个带有uid的数组,例如const uids = ['234', '343', '3242', ...]
如果我理解正确,您正在寻找DataSnapshot.hasChild()
。 通过它,您可以检查快照是否具有某个子节点。
就像是:
firebase
.database()
.ref('followers/2mvouwB0E0aEN5MnAhOLWaHiu6b2')
.once("value", snapshot => {
if (snapshot.hasChild('35nv594aotgcv')) {
console.log('Yes');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.