我正在使用Angular 5.2和Rxjs 5.6-forward-compat.3。
我正在尝试合并两个Firestore集合,并且我认为该问题与导入有关,但是我已经尝试了所有可能的组合和选项,所以不确定。
Here is the code:`IMPORTS:
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/combineLatest';
Here is my observable:
getActiveMedicationandCompliance(start: any): Observable<any[]> {
const email = this.authService.getLoginUserid();
const userDoc = this.afs.doc<User>(`users/${email}`);
return userDoc
.collection<any>(collection.MY_MEDICATION_CABINET, ref =>
ref.where('active', '==', true).orderBy('medicationName', 'asc')
)
.snapshotChanges()
.map(changes => {
return changes.map(action => {
let data = action.payload.doc.data();
data.id = action.payload.doc.id;
return userDoc
.collection<any>(collection.MY_MEDICATION_COMPLIANCE, ref =>
ref
.where('medicationCabinetId', '==', data.id)
.where('createdDate', '>=', start)
.orderBy('createdDate', 'asc')
)
.snapshotChanges()
.map(changes => {
changes.map(action => {
const dataCompliance = action.payload.doc.data();
dataCompliance.id = action.payload.doc.id;
return (data = Object.assign(
{},
{ ...dataCompliance, ...data }
));
});
});
});
})
.mergeMap(observables => Observable.combineLatest(observables));
}
`
答案 0 :(得分:0)
combineLatest不是运算符,而是可观察的导入的一部分:
import 'rxjs/observable/combineLatest';