X Tutup
The Wayback Machine - https://web.archive.org/web/20220322094137/https://github.com/angular/angularfire/pull/2113
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firestore): options to include document ID on valueChanges() #2113

Merged

Conversation

mjastrzebowski
Copy link
Contributor

@mjastrzebowski mjastrzebowski commented Jun 15, 2019

Checklist

  • Issue number for this PR: #2109
  • Docs included?: Yes
  • Test units included?: Yes
  • In a clean directory, yarn install, yarn test run successfully? Yes

Description

Continuation of #1976 - added idField option for document.valuChanges() to include the document ID on the emitted data payload. Updated documentation for this one and added some missing changes from the previous PR.

Code sample

documentRef.valueChanges({ idField: 'customID' }).subscribe()
// emits [ { customID: 'MrfFpRBfWLTd7LqiTt9u', ...data }, ... ]

@jamesdaniels jamesdaniels added this to the 5.3.0 milestone Jun 23, 2019
Copy link
Member

@jamesdaniels jamesdaniels left a comment

LGTM, thanks! Will merge once ready to cut 5.3

@leolara
Copy link

@leolara leolara commented Nov 20, 2019

This is very important feature, thank you

@leolara
Copy link

@leolara leolara commented Nov 20, 2019

I think this does not work if you call it on a collection instead of a document

@leolara
Copy link

@leolara leolara commented Nov 20, 2019

This is what I had to do to make it work on a collection. Perhaps there is better way, but this is my first week with rxjs:

readAll(): Observable<Listing[]> {
        return this.afs.collection<Listing>(COLLECTION_NAME).snapshotChanges().pipe(
            map((payloads) => {
                return payloads.map(({payload}) => {
                    return {
                        // tslint:disable-next-line:ban-types
                        ...payload.doc.data() as Object,
                        ...{id: payload.doc.id}
                    } as Listing;
                });
            })
        );
    }

@EdricChan03
Copy link
Contributor

@EdricChan03 EdricChan03 commented Apr 2, 2020

LGTM, thanks! Will merge once ready to cut 5.3

Are there any updates to this PR? It's been a while since release 5.3.

@jamesdaniels
Copy link
Member

@jamesdaniels jamesdaniels commented Apr 2, 2020

Whoops, meant to get this into 5.3 but working on 6 ate up all my time. Will get this into 6.1.

@kyleabens
Copy link

@kyleabens kyleabens commented Oct 30, 2020

Can this be added to 6.0.4?

@jamesdaniels
Copy link
Member

@jamesdaniels jamesdaniels commented Nov 11, 2020

New API so had to wait for a minor, will aim to get this in today for rc.1.

@jamesdaniels jamesdaniels merged commit 09ed22a into angular:master Nov 11, 2020
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
X Tutup