Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { DocumentSnapshot } from "@google-cloud/firestore";
- interface Entity {
- id: string;
- }
- const dataFromSnapshot = <T extends Entity>(
- snapshot: DocumentSnapshot
- ): T | undefined => {
- if (!snapshot.exists) return undefined;
- const data = snapshot.data() as any;
- return {
- ...data,
- id: snapshot.id
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement