火力地堡 - 通过用户ID从配置文件列表获取对象 [英] Firebase - Get object by userID from a list of profiles

查看:220
本文介绍了火力地堡 - 通过用户ID从配置文件列表获取对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过用户ID使用火力地堡的配置文件列表获取对象。

I'm trying to get an object by userID from a list of profiles using Firebase.

我编码Angular2与打字稿。
我必须火力地堡工作的参考,可以做类似推对象的其他命令等。

I'm coding in Angular2 with Typescript. I've got the reference to firebase working and can do other commands like push an object etc.

我只需要知道如何通过它的字段值例如提取目标的uid在这种情况

I just need to know how to extract an object by its field value e.g. uid in this case.

这里是我的code片断:

getUserProfileByUid(uid){
    console.log("Get profile by uid");

    var ref = new Firebase("https://markng2.firebaseio.com/profiles/uid");
    var data = ref.child(uid);

    console.log(data));     
}

*请参阅我的观点型材火力JSON附照片。

*See attached photo for view of my firebase profiles json.

在这里输入的形象描述

先谢谢了。

推荐答案

您可以使用查询。

var rootRef = new Firebase('<my-firebase-app>.firebaseio.com/');
var profileRef = rootRef.child('profiles');

// order by email and then find the specific email
var query = profileRef.orderByChild('email').equalTo('myemail@email.com');

// Do a one time read of that email
query.once('value', (snap) => console.log(snap.val()));

了解更多详细信息,火力地堡文档

这篇关于火力地堡 - 通过用户ID从配置文件列表获取对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆