You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
@Toxicable Want to send in a PR to export the type?
I hear you on the boilerplate method. However, we can't assume the id key name. A user could easily store id as something else entirely. The official SDK is looking into supporting auto applying __id__ to the doc.data() call and then stripping it on the update. That is the idea solution because it will be like $key except we don't have to do anything in AngularFire land to support it :)
DocumentChangeAction
dosen't appear to be exported as a public API, along with all the interfaces underinterfaces.ts
, not sure about the other interfaces butDocumentChangeAction
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 duplicationSpeaking 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
The text was updated successfully, but these errors were encountered: