0
첫 번째 호출에서받은 키를 기반으로 subcollection
의 데이터를 검색하려고합니다. 기본적으로 나는 각 사용자에 대해 각각 하나의 하위 수집 목록을 원합니다.Angularfire2 & Firestore - 컬렉션 목록의 모든 하위 수집 컨텐츠 검색
있지만
그것을 달성하기 위해 올바른 방법은 무엇입니까
아래pointRef
에서?
첫 번째 호출에서받은 키를 기반으로 subcollection
의 데이터를 검색하려고합니다. 기본적으로 나는 각 사용자에 대해 각각 하나의 하위 수집 목록을 원합니다.Angularfire2 & Firestore - 컬렉션 목록의 모든 하위 수집 컨텐츠 검색
있지만
그것을 달성하기 위해 올바른 방법은 무엇입니까
아래pointRef
에서?
나는 내 코드를 주석에 넣으려고했으나 대답으로 형식화 된 것이 더 좋다고 생각합니다.
먼저 pointRef
을 구독해야하며 이와 같이 코드를 변경할 수 있습니다.
getCurrentLeaderboard() {
return this.afs.collection('users').snapshotChanges().map(actions => {
return actions.map(a => {
const data = a.payload.doc.data()
const id = a.payload.doc.id;
const pointRef: Observable<any> = this.afs.object(`users/${id}/game`).valueChanges() // <--- Here
const pointsObserver = pointRef.subscribe(points => { //<--- And Here
return { id, first_name: data.first_name, point:points };
})
})
}
....
//Usage:
getCurrentLeaderboard.subscribe(points => this.points = points);
그리고이 기능을 많이 사용하려면 denormalize your data으로 시작해야합니다.
입력 해 주셔서 감사합니다. @Makah! 아직보기에 문제가 있습니다. 나는'id'와'first_name'을'