我是FireBase的新手,我正在尝试建立一个简单的数据库。这是我的数据:
{
"employees" : {
"employee1" : {
"name" : "Anthony"
},
"employee2" : {
"name" : "John",
"reviews" : {
"review1" : true,
"review2" : true,
"review3" : true
}
}
},
"leaders" : {
"leader1" : {
"company" : "Strawberry",
"name" : "Martin",
"reviews" : {
"review1" : true
}
},
"leader2" : {
"company" : "Blueberry",
"name" : "Carlos",
"reviews" : {
"review2" : true,
"review3" : true
}
},
"leader3" : {
"company" : "Greenberry",
"name" : "Peter"
}
},
"reviews" : {
"review1" : {
"comment" : "Test1",
"date" : "Thu Jul 06 2017 14:00:51 GMT+0200 (CEST)"
},
"review2" : {
"comment" : "Test2",
"date" : "Thu Jul 06 2017 14:00:51 GMT+0200 (CEST)"
},
"review3" : {
"comment" : "Test3",
"date" : "Thu Jul 06 2017 14:00:51 GMT+0200 (CEST)"
}
}
}
}
我想要以下功能:
我的问题如下:
作为一个例子,假设我想得到leader1的评论。
db.object('/leaders/leader1').subscribe(res => {
this.leader = res;
//THIS IS THE PROBLEM: GET REVIEWS ON LEADER
db.list('/reviews', {
query: {
equalTo: this.investor.reviews
}
}).subscribe(queriedList => {
this.reviews = queriedList
});
});
谢谢。