我在Firestore中有两个集合A和B,我正在使用Angular 5.2和Angularfire2。 A是根集合,A中的每个文档都有一个子集合B。
我面临以下挑战:
我尝试使用switchMap,concatMap,concatAll等,但是对于每种类型,我都会得到不同的输入错误。
const rootCollection = this.afs
.doc(collection.USERS + `/${email}`)
.collection<MyMeasurement>(collection.MY_MEASUREMENT, ref =>
ref.where('selected', '==', true).orderBy('name', 'asc')
)
.snapshotChanges()
.pipe(
map(changes => {
return changes.map(action => {
const data = action.payload.doc.data() as MyMeasurement;
data.id = action.payload.doc.id;
return data;
});
})
);
const concatCollection = rootCollection.pipe(concatMap(data => data.forEach(element => {
// her comes the inner observer
// Her is the error message:
// Argument of type '(data: MyMeasurement[]) => void' is not assignable to parameter of type '(value: MyMeasurement[], index: number) => ObservableInput<{}>'.
//Type 'void' is not assignable to type 'ObservableInput<{}>'.
})))
const subscribe.concatCollection(data => console.log(data));