Skip to content

Commit 8a6f8a5

Browse files
authored
Merge pull request #129 from berdyshev/support-withConverter
Avoid DocumentData prototype overriding (#128)
2 parents 75f2dcd + 29f62d7 commit 8a6f8a5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

firestore/helpers/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ export const snapshotToData = <T>(
1111
return undefined;
1212
}
1313

14-
return {
15-
...(transform
16-
? transform(snapshot.data(snapshotOptions))
17-
: snapshot.data(snapshotOptions)),
18-
...(idField ? { [idField]: snapshot.id } : null),
19-
...(refField ? { [refField]: snapshot.ref } : null),
20-
};
14+
let data = snapshot.data(snapshotOptions) as firebase.firestore.DocumentData;
15+
if (transform) {
16+
data = transform(data);
17+
}
18+
if (idField) {
19+
data[idField] = snapshot.id;
20+
}
21+
if (refField) {
22+
data[refField] = snapshot.ref;
23+
}
24+
25+
return data;
2126
};

0 commit comments

Comments
 (0)