我使用以下代码从firebase数据库中删除某些db对象。但是,由于某种原因.remove()
没有删除db对象,并且令人惊讶的是没有抛出错误,.then()
也正在执行。有人可以帮帮我吗?
try {
db1.ref('statements/' + nodeLocation).remove()
.then(function() {
console.log ("nodeLocation[" + i + "] " + nodeLocation + " deleted successfully! ");
}, (err) => {console.log(err)});
} catch (err) {
console.log ("Error while deleting!");
console.log (err);
console.log("Error:" + err.error_message);
}
答案 0 :(得分:0)
我明白了。上面的代码没有问题,但是,由于'nodeLocation'已经包含'statements /'而上面的代码再次为它添加前缀,因此引用不正确。因此,只需替换这行代码:
db1.ref('statements/' + nodeLocation).remove()
这一个:
db1.ref(nodeLocation).remove()
工作!