首页 > 解决方案 > 我如何专门查询firebase实时数据库中的字段

问题描述

阅读文档后,我一直在尝试对 firebase 数据库进行一些查询,但我不太了解发生了什么,我实际上想要获得字段标记“God is good”。这是我的代码

 const ref = db.ref("songs") //  reference to the  database
    try {
     ref.orderByChild(`God is good`).on("value", function(snapshot) {
     console.log(snapshot.val()); // the returned data from database
     snapshot.forEach(function(data) {
  
       });
          });
    } catch (error) {
            throw error
    }
    finally {
            
    }

这是我的数据结构

所有数据条目都返回。

标签: firebase

解决方案


推荐阅读