Skip to content

Proposal: Optionally return a document ID on valueChanges() #1973

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

Closed
codediodeio opened this issue Dec 14, 2018 · 4 comments
Closed

Proposal: Optionally return a document ID on valueChanges() #1973

codediodeio opened this issue Dec 14, 2018 · 4 comments

Comments

@codediodeio
Copy link
Contributor

codediodeio commented Dec 14, 2018

A major pain point with angularfire continues to be mapping a document ID to a collection query. I propose we add an optional withId argument to collection.valueChanges(). This can be a simple non-breaking change and I can PR it.

collection.valueChanges(withId?: string)

// emits [ { myIdKey: 'MrfFpRBfWLTd7LqiTt9u', ...data }, ... ]

This will greatly simplify the code below

// current requirement
ref.snapshotChanges()
      .pipe(
        map(actions => {
          return actions.map(a => {
            const data = a.payload.doc.data();
            const id = a.payload.doc.id;
            return { myIdKey: id, ...data };
          });
})

// after change 

ref.valueChanges('myIDKey')
@codercatdev
Copy link

Oh please yes!

@AJHanekom
Copy link

Yes please.

@balajkhan07
Copy link

That would be great.

@rtpHarry
Copy link
Contributor

rtpHarry commented Jan 5, 2020

This can be closed it was merged with #1976 (and thanks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants