How would I rewrite this function in the latest "modular" version of angular firestore?
getLatestEntries(limit = 5) {
return this.db.collectionGroup('Entries', ref => ref.orderBy('finishedTime', 'desc').limit(limit)).snapshotChanges().pipe(
map(actions => actions.map(a => <any>{
id: a.payload.doc.id,
changeType: a.type,
...<Entry>a.payload.doc.data()
}))
);
}
The idea is returning an Observable<Entry[]> with the added "changeType" attribute indicating "added/modified/deleted".
I tried using collectionSnapshots(), but they are missing the (change)"type" property. Also tried using docChanges(query(collectionGroup())), but that only returns the single updated document, not all of them like snapshotChanges() used to.