We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a82e2c0 + 0f2980d commit 81a807aCopy full SHA for 81a807a
firestore/helpers/index.ts
@@ -3,7 +3,10 @@ import { firestore } from 'firebase';
3
export const snapshotToData = (
4
snapshot: firestore.DocumentSnapshot,
5
idField?: string
6
-) => ({
7
- ...snapshot.data(),
8
- ...(idField ? { [idField]: snapshot.id } : null),
9
-});
+) => {
+ if (!snapshot.exists) return null;
+ return {
+ ...snapshot.data(),
10
+ ...(idField ? { [idField]: snapshot.id } : null),
11
+ };
12
+};
0 commit comments