[英]What is the correct way to check firebase db ref on client side(i.e. in javascript)?
While using firebaseDB.ref("some-node-ref-that-does-not-exist/")
how can I make a null check.使用
firebaseDB.ref("some-node-ref-that-does-not-exist/")
如何进行 null 检查。 This line of code still getting invoked with even above node does not exists in my firebase db.在我的 firebase 数据库中,这行代码仍然被调用,即使是上面的节点也不存在。
If you want to check if there is data at a specific node in the Realtime Database, you have to query this node and look if the DataSnapshot
exists.如果要检查实时数据库中特定节点是否有数据,则必须查询该节点并查看
DataSnapshot
是否存在。
With the JavaScript SDK you would do as follows, using the exists()
method:使用 JavaScript SDK 您可以使用
exists()
方法执行以下操作:
ref.once('value')
.then(function(dataSnapshot) {
if (dataSnapshot.exists()) {....}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.