我想删除值为“Screen2”的数据
{
"mobilereg" : {
"1245639856" : {
"screen" : "Screen2"
},
"1254789632" : {
"screen" : "Screen2"
},
"1452369852" : {
"screen" : "Screen2"
},
"2589632587" : {
"screen" : "Screen2"
}
}
}
删除屏幕值为“Screen2”的数字:
答案 0 :(得分:0)
要删除firebase中的值,您可以在firebase引用remove()
节点上使用mobilereg
函数,其中子值为Screen2
。
let mobileregRef = firebase.database().ref().child("mobilereg")
mobileregRef
.once('value', s => {
if (s.exists()) {
// map through objects returned from mobileregRef and map through the objects
Object.keys(s.val()).map(k => {
// deleting the node which contains `Screen2` as value
if(s.val()[k]=="Screen2"){
s.ref.remove()
}
})
}
})