Skip to content

Proposal: unwrapCollection and unwrapDocument operators #1820

Closed
@davideast

Description

@davideast

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions