如何使用angular-firebase 2从类型为reference的属性中检索数据

时间:2018-12-02 14:50:55

标签: angular firebase firebase-realtime-database angularfire2

我正在使用angular-firebase 2开发应用程序。

对象人中有人员和区域,并且有一个属性引用了已注册的区域:

enter image description here

我的棱角分明的人对象我是这样的:

     import { Injectable } from '@angular/core';
import { persona } from '../modelos/persona';
import { AngularFirestoreCollection, AngularFirestore } from 'angularfire2/firestore';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { actividades } from '../modelos/actividades';
import { actividad_persona } from '../modelos/actividad_persona';
import { area } from '../modelos/area';

@Injectable({
  providedIn: 'root'
})
export class PersonaService {
  private personaCollection: AngularFirestoreCollection<persona>
  persona: persona
  constructor(private afs: AngularFirestore) {
    this.personaCollection = this.afs.collection<persona>('persona')
  }
  getPersonaFindId(idPersona: string): Observable<persona> {
    return this.afs.collection<persona>("persona").doc(idPersona).snapshotChanges().pipe(map(actions => {
      const id = actions.payload.id;
      const data = actions.payload.data() as persona;
      data.areaRef.onSnapshot(p=>{

      })

      console.log(data.areaRef.id)
      return { id, ...data };
    }))

我的服务可以带出该人除该地区以外的所有数据:

$res = "Result:" . $_SESSION[myVar];

我将如何检索区域数据?谢谢

0 个答案:

没有答案