Skip to content

firestore: DocumentChangeAction is not exported #1249

@Toxicable

Description

@Toxicable

DocumentChangeAction dosen't appear to be exported as a public API, along with all the interfaces under interfaces.ts, not sure about the other interfaces but DocumentChangeAction is exposed by .snapshotChanges(), therefore it should also be exported.

Use Case

Transforming the data into data with it's id in a function to avoid code duplication

function addIdsToItems(items: DocumentChangeAction[]) {
  return items.map(a => {
    const data = a.payload.doc.data() as Pizza;
    const id = a.payload.doc.id;
    return { id, ...data };
  });
}

//use
this.itemsRef.snapshotChanges().map(addIdsToItems);

Speaking of which, it would be nice if AngularFire provided this or a similar function since it's super boiler plately and i'm sure everyone needs to use it

code ref: https://github.com/angular/angularfire2/blob/a3c746d6dedbeb8368d5acd4ed76d278494bfd64/src/firestore/interfaces.ts#L4

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