美好的一天。我有3个集合和架构:
locations :
- id (Auto generated by firebase)
- location_city
- location_country
venues:
- id ( auto generated by firebase)
- venue_name
- venue_address
- location_id (this is related to the locations collection)
events:
- id (auto generated by firebase)
- event_name
- venues:
[0] venue_id_1
[1] venue_id_2
我要过滤的事件属于一个位置,例如,列出在日本东京可用的所有事件
这是到目前为止我尝试过的(Angular 7),我是Firebase的新手,所以不确定我在写对还是错...
//过滤器组件调用
filterEvents() {
this.filterByEvents = true;
if (!this.executedEventFilter) {
this.executedEventFilter = true;
this.LocationManagementService.filterByEvents(this.LocationManagementService.locationId);
}
该服务的句柄
filterByEvents(locationId) {
const locationsRef = firebase.database().ref().child("locations");
const venuesRef = firebase.database().ref().child("venues");
const eventsRef = firebase.database().ref().child("events");
return new Promise<any>((resolve, reject) => {
eventsRef.on('child_added', (snapEvent) => {
console.log(snapEvent);
})
});
}