Skip to content

Commit a607a25

Browse files
committed
Expand FirestoreDataConverter's documentation to explain the concepts of AppModel and DbModel
1 parent 9b07bba commit a607a25

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

packages/firestore/src/api/snapshot.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ import { SnapshotListenOptions } from './reference_impl';
4848
* Using the converter allows you to specify generic type arguments when
4949
* storing and retrieving objects from Firestore.
5050
*
51+
* In this context, an "AppModel" is a class that is used in an application to
52+
* package together related information and functionality. Such a class could,
53+
* for example, have properties with complex, nested data types, properties used
54+
* for memoization, properties of types not supported by Firestore (such as
55+
* `symbol` and `bigint`), and helper functions that perform compound
56+
* operations. Such classes are not suitable or possible to store into a
57+
* Firestore database. Instead, instances of such classes need to be converted
58+
* to "plain old JavaScript objects" (POJOs), objects with only primitive
59+
* properties, potentially nested inside other objects or arrays. In this
60+
* context, this type is referred to as the "DbModel" and would be an object
61+
* suitable for persisting into Firestore. For convenience, applications can
62+
* implement `FirestoreDataConverter` and register the converter with Firestore
63+
* objects, such a `DocumentReference` or `Query`, to automatically convert
64+
* `AppModel` to `DbModel` when storing into Firestore, and convert `DbModel`
65+
* back to `AppModel` when retrieving from Firestore.
66+
*
5167
* @example
5268
*
5369
* Simple Example

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ import { AbstractUserDataWriter } from './user_data_writer';
4646
* Using the converter allows you to specify generic type arguments when
4747
* storing and retrieving objects from Firestore.
4848
*
49+
* In this context, an "AppModel" is a class that is used in an application to
50+
* package together related information and functionality. Such a class could,
51+
* for example, have properties with complex, nested data types, properties used
52+
* for memoization, properties of types not supported by Firestore (such as
53+
* `symbol` and `bigint`), and helper functions that perform compound
54+
* operations. Such classes are not suitable or possible to store into a
55+
* Firestore database. Instead, instances of such classes need to be converted
56+
* to "plain old JavaScript objects" (POJOs), objects with only primitive
57+
* properties, potentially nested inside other objects or arrays. In this
58+
* context, this type is referred to as the "DbModel" and would be an object
59+
* suitable for persisting into Firestore. For convenience, applications can
60+
* implement `FirestoreDataConverter` and register the converter with Firestore
61+
* objects, such a `DocumentReference` or `Query`, to automatically convert
62+
* `AppModel` to `DbModel` when storing into Firestore, and convert `DbModel`
63+
* back to `AppModel` when retrieving from Firestore.
64+
*
4965
* @example
5066
*
5167
* Simple Example

0 commit comments

Comments
 (0)