Thanks to #1973 and #1976 (@codediodeio 馃敟) the newest version of AngularFire allows to use valueChanges() in a way that it also maps the ID of the document to the document data that is being returned in addition to the document data itself.
const tasks: Observable<Task[]> = this.firestore.collection<Task>('tasks').valueChanges({ idField: 'id' });
This currently only works when working with a collection() call.
It may also be nice to do the same when reading a single doc() like so:
const taskId = 'abcdefg';
const task: Observable<Task> = this.firestore.doc<Task>(`tasks/${taskId}`).valueChanges({ idField: 'id' });
I'm amenable to this, any interest in putting together a PR?
Sounds like a great opportunity to start contributing :) On my way with the PR
We should also include in collectionGroup as well. Currently the documentation reads that idField can be used in valueChanges(), however it code currently expects 0 arguments
@geogramdotcom Thanks for the comment, I thought that I checked that case too, but I might miss something. I will update PR if that's right
Is the suggestion above available? I mean, how observe a single document? I am struggling to figure out how do it and add an idToken when using observing a collection? I would be grateful if someone can answer my question in https://stackoverflow.com/questions/61355351/angular-and-firestore-firebaseerror-missing-or-insufficient-permissions-how-a
Should be addressed in 6.1.0-rc.1
Most helpful comment
Sounds like a great opportunity to start contributing :) On my way with the PR