Skip to content

Proposal: unwrapCollection and unwrapDocument operators #1820

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
davideast opened this issue Aug 17, 2018 · 1 comment
Closed

Proposal: unwrapCollection and unwrapDocument operators #1820

davideast opened this issue Aug 17, 2018 · 1 comment

Comments

@davideast
Copy link
Collaborator

Easier access to a document’s ID

Getting the id mapped to a single document has also long been a pain point, so we thinking of introducing a new operator to simplify this process:

Collection

// using the new docs property in issue #1819 
const items$ = af.collection(‘items’).docs
  .pipe(
     unwrapCollection({ id: ‘key’  })
  )
  .subscribe(items => {
    const first = docs[0];
    console.log(first.key); // they id is mapped to each object!
  });

Document

// using the .doc property in issue #1819 
const items$ = af.collection(‘items/1).doc
  .pipe(
     unwrapDoc({ id: ‘key’  })
  )
  .subscribe(item => {
    console.log(item.key);
  });

Leave a comment letting us know what you think.

@hiepxanh
Copy link
Contributor

I love this. I think that is great

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

3 participants