从多个索引(节点)获取 firebase 数据

Get firebase data from several indexes (nodes)

这是我的数据库示例:

目标是在节点号 1 中列出用户的所有待定约会。然后在节点号 2 中检索该约会的一些数据,尤其是医生 ID,以最终获得有关该医生的所有详细信息。 我可以使用以下代码将我的数据从 1 号映射到 2 号:

idPatient: string
  pendingAppointment: any
  noConnection: boolean
  constructor(public navCtrl: NavController, public navParams: NavParams, public network: NetworkProvider, public firebaseProvider: FirebaseServiceProvider) {
    this.idPatient = this.navParams.get('user')
      this.pendingAppointment = this.firebaseProvider.list('patientList/'+this.idPatient+'/appointments/pending')
      .map(appointments => {
        return appointments.map(appointment => {
        return  this.firebaseProvider.object('appointments/' + appointment.$key )
        })
      })

..并使用 :

在我的 html 中获取数据
<div *ngFor="let appointment of pendingAppointment | async;let i = index">
{{ (appointment | async)?.praticien }}
        </div>

但我被这个愚蠢的问题困住了。 如何映射 3 号节点并在 html 中检索 3 号节点的详细信息?

也许有人可以帮助我。

我认为这样的事情应该可行...

this.pendingAppointment = this.db.list('patientList/'+this.idPatient+'/appointments/pending').snapshotChanges().map(appointments => {
    return appointments.map(appointment => ({
      appointments: this.db.object('appointments/' + appointment.payload.key).valueChanges().map(
        app => ({
          place: this.db.object('practiciensDetails/' + app.practicien).valueChanges()
        })
      )
    }));
  });

然后对于你的 html,像这样:

<div *ngFor="let appointment of pendingAppointment | async;let i = index">
  {{ (appointment | async)?.praticien }}
  {{ ((appointment | async)?.place | async)?.firstname }}
</div>

希望对您有所帮助!经过几个小时的摆弄,我能够在我的项目中得到类似的东西。我记得我花了几天时间才迈出两层深度的第一步。在这种情况下,第三级实际上只归结为 'mapping' 对象的语法,而不是我花了很长时间才找到的列表。