Skip to content

Commit 055c384

Browse files
committed
Improve fromFirestore() docs to more clearly identify how non-conforming data could have been written into Firestore
1 parent a607a25 commit 055c384

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/firestore/src/api/snapshot.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,14 @@ export interface FirestoreDataConverter<
266266
* `snapshot.data(options)`.
267267
*
268268
* Generally, the data returned from `snapshot.data()` can be cast to
269-
* `DbModelType`; however, this is not guaranteed as writes to the database
270-
* may have occurred without a type converter enforcing this specific layout.
269+
* `DbModelType`; however, this is not guaranteed because Firestore does not
270+
* enforce a schema on the database. For example, writes from a previous
271+
* version of the application or writes from another client that did not use a
272+
* type converter could have written data with different properties and/or
273+
* property types. The implementation will need to choose whether to
274+
* gracefully recover from non-conforming data or throw an error.
275+
*
276+
* To override this method, see {@link (FirestoreDataConverter.fromFirestore:1)}.
271277
*
272278
* @param snapshot - A `QueryDocumentSnapshot` containing your data and metadata.
273279
* @param options - The `SnapshotOptions` from the initial call to `data()`.

packages/firestore/src/lite-api/snapshot.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,14 @@ export interface FirestoreDataConverter<
266266
* type `AppModelType`. You can access your data by calling:
267267
* `snapshot.data()`.
268268
*
269+
*
269270
* Generally, the data returned from `snapshot.data()` can be cast to
270-
* `DbModelType`; however, this is not guaranteed as writes to the database
271-
* may have occurred without a type converter enforcing this specific layout.
271+
* `DbModelType`; however, this is not guaranteed because Firestore does not
272+
* enforce a schema on the database. For example, writes from a previous
273+
* version of the application or writes from another client that did not use a
274+
* type converter could have written data with different properties and/or
275+
* property types. The implementation will need to choose whether to
276+
* gracefully recover from non-conforming data or throw an error.
272277
*
273278
* @param snapshot - A `QueryDocumentSnapshot` containing your data and
274279
* metadata.

0 commit comments

Comments
 (0)