简体   繁体   English

从Firebase(NodeJ)检索数据

[英]Retrieving data from Firebase (NodeJs)

I'm kind of new to Firebase and learning it step by step(background is mongoDB and SQL). 我是Firebase的新手,并且逐步学习它(背景是mongoDB和SQL)。 Right now I'm trying to retrieve data on the basis of id from the database. 现在,我正在尝试基于id从数据库中检索数据。 Now the problem is I can't find anything which will help me in retrieving the data from the database. 现在的问题是,我找不到任何可以帮助我从数据库检索数据的东西。

the thing that I was able to find was this : 我能够找到的东西是这样的:

var ref = firebaseConnection.connect.ref(nodePath+ "/trip/id");
ref.on("child_added", function(snapshot) {
    console.log("INSIDE");
        var data = snapshot.val();
        console.log("data is : " + data);
});

My understanding is that this will work when a child is added so please help me out that is there any way like this ref.find(id) which would help me in finding something from the database or will I have to do something like child_added (like the code mentioned above) to get something from the database. 我的理解是,这在添加孩子时会起作用,因此请帮助我解决诸如ref.find(id) ,该方法将帮助我从数据库中查找内容,或者我必须执行诸如child_added (就像上面提到的代码)从数据库中获取一些东西。

您可以通过对地址的GET HTTP调用将其检索,并在引用的末尾添加“ .json”。

var path = nodePath + "/trip/" + id + ".json";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM