Last active
July 23, 2020 13:13
-
-
Save ajitzero/a1f9d0d7f65a2a0bb1b98c84a5a58aee to your computer and use it in GitHub Desktop.
Convert snapshots received from Firestore to TypeScript-safe objects with ID (using generics).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function createSnapshotObjects<T>(snapshots): Array<T> { | |
| return snapshots.map(snap => { | |
| return { | |
| id: snap.payload.doc.id, | |
| ...snap.payload.doc.data() | |
| }; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment