Skip to content

Commit 0708d31

Browse files
committed
update class/function docs
1 parent 67e4beb commit 0708d31

13 files changed

+125
-81
lines changed

docs-devsite/firestore_.collectionreference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export declare class CollectionReference<AppModelType = DocumentData, DbModelTyp
3232
3333
| Method | Modifiers | Description |
3434
| --- | --- | --- |
35-
| [withConverter(converter)](./firestore_.collectionreference.md#collectionreferencewithconverter) | | Applies a custom data converter to this <code>CollectionReference</code>, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned <code>CollectionReference</code> instance, the provided converter will convert between Firestore data and your custom type <code>U</code>. |
35+
| [withConverter(converter)](./firestore_.collectionreference.md#collectionreferencewithconverter) | | Applies a custom data converter to this <code>CollectionReference</code>, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned <code>CollectionReference</code> instance, the provided converter will convert between Firestore data of type <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
3636
| [withConverter(converter)](./firestore_.collectionreference.md#collectionreferencewithconverter) | | Removes the current converter. |
3737
3838
## CollectionReference.id
@@ -77,7 +77,7 @@ readonly type = "collection";
7777
7878
## CollectionReference.withConverter()
7979
80-
Applies a custom data converter to this `CollectionReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned `CollectionReference` instance, the provided converter will convert between Firestore data and your custom type `U`<!-- -->.
80+
Applies a custom data converter to this `CollectionReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned `CollectionReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`<!-- -->.
8181
8282
<b>Signature:</b>
8383
@@ -95,7 +95,7 @@ withConverter<NewAppModelType, NewDbModelType extends DocumentData>(converter: F
9595
9696
[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;NewAppModelType, NewDbModelType&gt;
9797
98-
A `CollectionReference<U>` that uses the provided converter.
98+
A `CollectionReference` that uses the provided converter.
9999
100100
## CollectionReference.withConverter()
101101
@@ -117,5 +117,5 @@ withConverter(converter: null): CollectionReference<DocumentData, DocumentData>;
117117
118118
[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->, [DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;
119119
120-
A `CollectionReference<DocumentData>` that does not use a converter.
120+
A `CollectionReference<DocumentData, DocumentData>` that does not use a converter.
121121

docs-devsite/firestore_.documentreference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export declare class DocumentReference<AppModelType = DocumentData, DbModelType
3333

3434
| Method | Modifiers | Description |
3535
| --- | --- | --- |
36-
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this <code>DocumentReference</code>, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned <code>DocumentReference</code> instance, the provided converter will convert between Firestore data and your custom type <code>U</code>. |
36+
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this <code>DocumentReference</code>, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned <code>DocumentReference</code> instance, the provided converter will convert between Firestore data of type <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
3737
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Removes the current converter. |
3838

3939
## DocumentReference.converter
@@ -98,7 +98,7 @@ readonly type = "document";
9898

9999
## DocumentReference.withConverter()
100100

101-
Applies a custom data converter to this `DocumentReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data and your custom type `U`<!-- -->.
101+
Applies a custom data converter to this `DocumentReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`<!-- -->.
102102

103103
<b>Signature:</b>
104104

@@ -116,7 +116,7 @@ withConverter<NewAppModelType, NewDbModelType extends DocumentData>(converter: F
116116

117117
[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;NewAppModelType, NewDbModelType&gt;
118118

119-
A `DocumentReference<U>` that uses the provided converter.
119+
A `DocumentReference` that uses the provided converter.
120120

121121
## DocumentReference.withConverter()
122122

@@ -138,5 +138,5 @@ withConverter(converter: null): DocumentReference<DocumentData, DocumentData>;
138138

139139
[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->, [DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;
140140

141-
A `DocumentReference<DocumentData>` that does not use a converter.
141+
A `DocumentReference<DocumentData, DocumentData>` that does not use a converter.
142142

docs-devsite/firestore_.firestoredataconverter.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk
1010
{% endcomment %}
1111

1212
# FirestoreDataConverter interface
13-
Converter used by `withConverter()` to transform user objects of type `T` into Firestore data.
13+
Converter used by `withConverter()` to transform user objects of type `AppModelType` into Firestore data of type `DbModelType`<!-- -->.
1414

1515
Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.
1616

@@ -24,13 +24,15 @@ export declare interface FirestoreDataConverter<AppModelType, DbModelType extend
2424

2525
| Method | Description |
2626
| --- | --- |
27-
| [fromFirestore(snapshot, options)](./firestore_.firestoredataconverter.md#firestoredataconverterfromfirestore) | Called by the Firestore SDK to convert Firestore data into an object of type T. You can access your data by calling: <code>snapshot.data(options)</code>. |
28-
| [toFirestore(modelObject)](./firestore_.firestoredataconverter.md#firestoredataconvertertofirestore) | Called by the Firestore SDK to convert a custom model object of type <code>T</code> into a plain JavaScript object (suitable for writing directly to the Firestore database). To use <code>set()</code> with <code>merge</code> and <code>mergeFields</code>, <code>toFirestore()</code> must be defined with <code>PartialWithFieldValue&lt;T&gt;</code>.<!-- -->The <code>WithFieldValue&lt;T&gt;</code> type extends <code>T</code> to also allow FieldValues such as [deleteField()](./firestore_.md#deletefield) to be used as property values. |
29-
| [toFirestore(modelObject, options)](./firestore_.firestoredataconverter.md#firestoredataconvertertofirestore) | Called by the Firestore SDK to convert a custom model object of type <code>T</code> into a plain JavaScript object (suitable for writing directly to the Firestore database). Used with [setDoc()](./firestore_.md#setdoc)<!-- -->, and with <code>merge:true</code> or <code>mergeFields</code>.<!-- -->The <code>PartialWithFieldValue&lt;T&gt;</code> type extends <code>Partial&lt;T&gt;</code> to allow FieldValues such as [arrayUnion()](./firestore_.md#arrayunion) to be used as property values. It also supports nested <code>Partial</code> by allowing nested fields to be omitted. |
27+
| [fromFirestore(snapshot, options)](./firestore_.firestoredataconverter.md#firestoredataconverterfromfirestore) | Called by the Firestore SDK to convert Firestore data into an object of type <code>AppModelType</code>. You can access your data by calling: <code>snapshot.data(options)</code>.<!-- -->Generally, the data returned from <code>snapshot.data()</code> can be cast to <code>DbModelType</code>; however, this is not guaranteed as writes to the database may have occurred without a type converter enforcing this specific layout. |
28+
| [toFirestore(modelObject)](./firestore_.firestoredataconverter.md#firestoredataconvertertofirestore) | Called by the Firestore SDK to convert a custom model object of type <code>AppModelType</code> into a plain JavaScript object (suitable for writing directly to the Firestore database) of type <code>DbModelType</code>. To use <code>set()</code> with <code>merge</code> and <code>mergeFields</code>, <code>toFirestore()</code> must be defined with <code>PartialWithFieldValue&lt;AppModelType&gt;</code>.<!-- -->The <code>WithFieldValue&lt;T&gt;</code> type extends <code>T</code> to also allow FieldValues such as [deleteField()](./firestore_.md#deletefield) to be used as property values. |
29+
| [toFirestore(modelObject, options)](./firestore_.firestoredataconverter.md#firestoredataconvertertofirestore) | Called by the Firestore SDK to convert a custom model object of type <code>AppModelType</code> into a plain JavaScript object (suitable for writing directly to the Firestore database) of type <code>DbModelType</code>. Used with [setDoc()](./firestore_.md#setdoc)<!-- -->, and with <code>merge:true</code> or <code>mergeFields</code>.<!-- -->The <code>PartialWithFieldValue&lt;T&gt;</code> type extends <code>Partial&lt;T&gt;</code> to allow FieldValues such as [arrayUnion()](./firestore_.md#arrayunion) to be used as property values. It also supports nested <code>Partial</code> by allowing nested fields to be omitted. |
3030

3131
## FirestoreDataConverter.fromFirestore()
3232

33-
Called by the Firestore SDK to convert Firestore data into an object of type T. You can access your data by calling: `snapshot.data(options)`<!-- -->.
33+
Called by the Firestore SDK to convert Firestore data into an object of type `AppModelType`<!-- -->. You can access your data by calling: `snapshot.data(options)`<!-- -->.
34+
35+
Generally, the data returned from `snapshot.data()` can be cast to `DbModelType`<!-- -->; however, this is not guaranteed as writes to the database may have occurred without a type converter enforcing this specific layout.
3436

3537
<b>Signature:</b>
3638

@@ -51,7 +53,7 @@ AppModelType
5153

5254
## FirestoreDataConverter.toFirestore()
5355

54-
Called by the Firestore SDK to convert a custom model object of type `T` into a plain JavaScript object (suitable for writing directly to the Firestore database). To use `set()` with `merge` and `mergeFields`<!-- -->, `toFirestore()` must be defined with `PartialWithFieldValue<T>`<!-- -->.
56+
Called by the Firestore SDK to convert a custom model object of type `AppModelType` into a plain JavaScript object (suitable for writing directly to the Firestore database) of type `DbModelType`<!-- -->. To use `set()` with `merge` and `mergeFields`<!-- -->, `toFirestore()` must be defined with `PartialWithFieldValue<AppModelType>`<!-- -->.
5557

5658
The `WithFieldValue<T>` type extends `T` to also allow FieldValues such as [deleteField()](./firestore_.md#deletefield) to be used as property values.
5759

@@ -73,7 +75,7 @@ toFirestore(modelObject: WithFieldValue<AppModelType>): WithFieldValue<DbModelTy
7375

7476
## FirestoreDataConverter.toFirestore()
7577

76-
Called by the Firestore SDK to convert a custom model object of type `T` into a plain JavaScript object (suitable for writing directly to the Firestore database). Used with [setDoc()](./firestore_.md#setdoc)<!-- -->, and with `merge:true` or `mergeFields`<!-- -->.
78+
Called by the Firestore SDK to convert a custom model object of type `AppModelType` into a plain JavaScript object (suitable for writing directly to the Firestore database) of type `DbModelType`<!-- -->. Used with [setDoc()](./firestore_.md#setdoc)<!-- -->, and with `merge:true` or `mergeFields`<!-- -->.
7779

7880
The `PartialWithFieldValue<T>` type extends `Partial<T>` to allow FieldValues such as [arrayUnion()](./firestore_.md#arrayunion) to be used as property values. It also supports nested `Partial` by allowing nested fields to be omitted.
7981

@@ -106,15 +108,20 @@ class Post {
106108
}
107109
}
108110
111+
interface PostDbModel {
112+
title: string;
113+
author: string;
114+
}
115+
109116
const postConverter = {
110-
toFirestore(post: WithFieldValue<Post>): DocumentData {
117+
toFirestore(post: WithFieldValue<Post>): PostDbModel {
111118
return {title: post.title, author: post.author};
112119
},
113120
fromFirestore(
114121
snapshot: QueryDocumentSnapshot,
115122
options: SnapshotOptions
116123
): Post {
117-
const data = snapshot.data(options)!;
124+
const data = snapshot.data(options) as PostDbModel;
118125
return new Post(data.title, data.author);
119126
}
120127
};

docs-devsite/firestore_.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ https://github.com/firebase/firebase-js-sdk
153153
| [DocumentChange](./firestore_.documentchange.md#documentchange_interface) | A <code>DocumentChange</code> represents a change to the documents matching a query. It contains the document affected and the type of change that occurred. |
154154
| [DocumentData](./firestore_.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc)<!-- -->) consists of fields mapped to values. |
155155
| [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.<!-- -->Note: This interface is "experimental" and is subject to change.<!-- -->See <code>FirestoreSettings.experimentalAutoDetectLongPolling</code>, <code>FirestoreSettings.experimentalForceLongPolling</code>, and <code>FirestoreSettings.experimentalLongPollingOptions</code>. |
156-
| [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by <code>withConverter()</code> to transform user objects of type <code>T</code> into Firestore data.<!-- -->Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore. |
156+
| [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by <code>withConverter()</code> to transform user objects of type <code>AppModelType</code> into Firestore data of type <code>DbModelType</code>.<!-- -->Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore. |
157157
| [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. |
158158
| [Index](./firestore_.index.md#index_interface) | <b><i>(BETA)</i></b> The SDK definition of a Firestore index. |
159159
| [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | <b><i>(BETA)</i></b> A list of Firestore indexes to speed up local query execution.<!-- -->See [JSON Format](https://firebase.google.com/docs/reference/firestore/indexes/#json_format) for a description of the format of the index definition. |

docs-devsite/firestore_.query.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export declare class Query<AppModelType = DocumentData, DbModelType extends Docu
3737
| Method | Modifiers | Description |
3838
| --- | --- | --- |
3939
| [withConverter(converter)](./firestore_.query.md#querywithconverter) | | Removes the current converter. |
40-
| [withConverter(converter)](./firestore_.query.md#querywithconverter) | | Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you call [getDocs()](./firestore_.md#getdocs) with the returned query, the provided converter will convert between Firestore data and your custom type <code>U</code>. |
40+
| [withConverter(converter)](./firestore_.query.md#querywithconverter) | | Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you call [getDocs()](./firestore_.md#getdocs) with the returned query, the provided converter will convert between Firestore data of type <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
4141

4242
## Query.(constructor)
4343

@@ -99,11 +99,11 @@ withConverter(converter: null): Query<DocumentData, DocumentData>;
9999

100100
[Query](./firestore_.query.md#query_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->, [DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;
101101

102-
A `Query<DocumentData>` that does not use a converter.
102+
A `Query<DocumentData, DocumentData>` that does not use a converter.
103103

104104
## Query.withConverter()
105105

106-
Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you call [getDocs()](./firestore_.md#getdocs) with the returned query, the provided converter will convert between Firestore data and your custom type `U`<!-- -->.
106+
Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you call [getDocs()](./firestore_.md#getdocs) with the returned query, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`<!-- -->.
107107

108108
<b>Signature:</b>
109109

@@ -121,5 +121,5 @@ withConverter<NewAppModelType, NewDbModelType extends DocumentData>(converter: F
121121

122122
[Query](./firestore_.query.md#query_class)<!-- -->&lt;NewAppModelType, NewDbModelType&gt;
123123

124-
A `Query<U>` that uses the provided converter.
124+
A `Query` that uses the provided converter.
125125

0 commit comments

Comments
 (0)