例如 - 如何获取与email = -L1BchvA8NaQ9Yh7CjS_
匹配的节点tomcruise@firebasemyapp.com
?当数据库看起来像
{
"-L1BchvA8NaQ9Yh7CjS_" : {
"createdAt" : 1514187972592,
"displayName" : "tom cruise",
"email" : "tomcruise@firebasemyapp.com",
"firstName" : "tom",
"lastName" : "cruise",
"profileLink" : "https://reactjs.org/logo-og.png",
"status" : "happy christmas"
},
"-L1CcUEBOECrJJozlHJv" : {
"createdAt" : 1514204689673,
"displayName" : "Robert John Downey Jr",
"email" : "robertjohndowneyjr@firebasemyapp.com",
"firstName" : "Rober John",
"lastName" : "Downey Jr",
"profileLink" : "https://reactjs.org/logo-og.png",
"status" : "happy christmas"
},
}
编辑: -
我正在使用react-native.js
。
答案 0 :(得分:2)
你没有提到你正在使用的语言,但我会用javascript回答,并且改成另一种语言应该不难。
myvar
答案 1 :(得分:1)
我从Common SQL Queries converted for the Firebase Database找到了解决方案。
var currentUserUID = firebase.auth().currentUser.uid;
let dbRef = firebase.database().ref("ARUserProfiles/" + currentUserUID);
dbRef
.orderByChild("email")
.equalTo("tomcruise@firebasemyapp.com")
.once(
"value",
response => {
const val = response.val();
let responsePayload;
if (val) {
responsePayload = Object.entries(val);
console.log("ARUserProfiles :-", responsePayload);
}
},
error => {
console.log(error);
}
);