Skip to content

Commit 95b69f6

Browse files
committed
docgen
1 parent 5ea4ea5 commit 95b69f6

File tree

5 files changed

+61
-7
lines changed

5 files changed

+61
-7
lines changed

common/api-review/firestore.api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,11 @@ export class DocumentSnapshot<AppModelType = DocumentData, DbModelType extends D
174174
protected constructor();
175175
data(options?: SnapshotOptions): AppModelType | undefined;
176176
exists(): this is QueryDocumentSnapshot<AppModelType, DbModelType>;
177-
// (undocumented)
178177
static fromJSON<AppModelType, DbModelType extends DocumentData = DocumentData>(db: Firestore, json: object, converter: FirestoreDataConverter<AppModelType, DbModelType>): DocumentSnapshot<AppModelType, DbModelType>;
179178
get(fieldPath: string | FieldPath, options?: SnapshotOptions): any;
180179
get id(): string;
181180
readonly metadata: SnapshotMetadata;
182181
get ref(): DocumentReference<AppModelType, DbModelType>;
183-
// (undocumented)
184182
toJSON(): object;
185183
}
186184

@@ -651,12 +649,10 @@ export class QuerySnapshot<AppModelType = DocumentData, DbModelType extends Docu
651649
get docs(): Array<QueryDocumentSnapshot<AppModelType, DbModelType>>;
652650
get empty(): boolean;
653651
forEach(callback: (result: QueryDocumentSnapshot<AppModelType, DbModelType>) => void, thisArg?: unknown): void;
654-
// (undocumented)
655652
static fromJSON<AppModelType, DbModelType extends DocumentData = DocumentData>(db: Firestore, json: object): QuerySnapshot<AppModelType, DbModelType> | null;
656653
readonly metadata: SnapshotMetadata;
657654
readonly query: Query<AppModelType, DbModelType>;
658655
get size(): number;
659-
// (undocumented)
660656
toJSON(): object;
661657
}
662658

docs-devsite/firestore_.documentsnapshot.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export declare class DocumentSnapshot<AppModelType = DocumentData, DbModelType e
4040
| --- | --- | --- |
4141
| [data(options)](./firestore_.documentsnapshot.md#documentsnapshotdata) | | Retrieves all fields in the document as an <code>Object</code>. Returns <code>undefined</code> if the document doesn't exist.<!-- -->By default, <code>serverTimestamp()</code> values that have not yet been set to their final value will be returned as <code>null</code>. You can override this by passing an options object. |
4242
| [exists()](./firestore_.documentsnapshot.md#documentsnapshotexists) | | Returns whether or not the data exists. True if the document exists. |
43+
| [fromJSON(db, json, converter)](./firestore_.documentsnapshot.md#documentsnapshotfromjson) | <code>static</code> | Builds a <code>DocumentSnapshot</code> instance from a JSON object created by [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson)<!-- -->. |
4344
| [get(fieldPath, options)](./firestore_.documentsnapshot.md#documentsnapshotget) | | Retrieves the field specified by <code>fieldPath</code>. Returns <code>undefined</code> if the document or field doesn't exist.<!-- -->By default, a <code>serverTimestamp()</code> that has not yet been set to its final value will be returned as <code>null</code>. You can override this by passing an options object. |
44-
| [toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) | | |
45+
| [toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) | | Returns a JSON-serializable representation of this <code>DocumentSnapshot</code> instance. |
4546

4647
## DocumentSnapshot.(constructor)
4748

@@ -120,6 +121,30 @@ exists(): this is QueryDocumentSnapshot<AppModelType, DbModelType>;
120121

121122
this is [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class)<!-- -->&lt;AppModelType, DbModelType&gt;
122123

124+
## DocumentSnapshot.fromJSON()
125+
126+
Builds a `DocumentSnapshot` instance from a JSON object created by [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson)<!-- -->.
127+
128+
<b>Signature:</b>
129+
130+
```typescript
131+
static fromJSON<AppModelType, DbModelType extends DocumentData = DocumentData>(db: Firestore, json: object, converter: FirestoreDataConverter<AppModelType, DbModelType>): DocumentSnapshot<AppModelType, DbModelType>;
132+
```
133+
134+
#### Parameters
135+
136+
| Parameter | Type | Description |
137+
| --- | --- | --- |
138+
| db | [Firestore](./firestore_.firestore.md#firestore_class) | |
139+
| json | object | a JSON object represention of a <code>DocumentSnapshot</code> instance. |
140+
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;AppModelType, DbModelType&gt; | Converts objects to and from Firestore. |
141+
142+
<b>Returns:</b>
143+
144+
[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<!-- -->&lt;AppModelType, DbModelType&gt;
145+
146+
an instance of [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs.
147+
123148
## DocumentSnapshot.get()
124149

125150
Retrieves the field specified by `fieldPath`<!-- -->. Returns `undefined` if the document or field doesn't exist.
@@ -147,6 +172,8 @@ The data at the specified field location or undefined if no such field exists in
147172

148173
## DocumentSnapshot.toJSON()
149174

175+
Returns a JSON-serializable representation of this `DocumentSnapshot` instance.
176+
150177
<b>Signature:</b>
151178

152179
```typescript
@@ -156,3 +183,5 @@ toJSON(): object;
156183

157184
object
158185

186+
a JSON representation of this object.
187+

docs-devsite/firestore_.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ export declare function onSnapshot<AppModelType, DbModelType extends DocumentDat
644644
| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. |
645645
| snapshotJson | object | A JSON object generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson)<!-- -->. |
646646
| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<!-- -->&lt;AppModelType, DbModelType&gt;) =&gt; void | A callback to be called every time a new <code>DocumentSnapshot</code> is available. |
647-
| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)<!-- -->) =&gt; void | A callback to be called if the listen fails or is cancelled. No fruther callbacks will occur. |
647+
| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)<!-- -->) =&gt; void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. |
648648
| onCompletion | () =&gt; void | Can be provided, but will not be called since streams are never ending. |
649649
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;DbModelType&gt; | An optional object that converts objects from Firestore before the onNext listener is invoked. |
650650

docs-devsite/firestore_.querysnapshot.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export declare class QuerySnapshot<AppModelType = DocumentData, DbModelType exte
3434
| --- | --- | --- |
3535
| [docChanges(options)](./firestore_.querysnapshot.md#querysnapshotdocchanges) | | Returns an array of the documents changes since the last snapshot. If this is the first snapshot, all documents will be in the list as 'added' changes. |
3636
| [forEach(callback, thisArg)](./firestore_.querysnapshot.md#querysnapshotforeach) | | Enumerates all of the documents in the <code>QuerySnapshot</code>. |
37-
| [toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) | | |
37+
| [fromJSON(db, json)](./firestore_.querysnapshot.md#querysnapshotfromjson) | <code>static</code> | Builds a <code>QuerySnapshot</code> instance from a JSON object created by [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson)<!-- -->. |
38+
| [toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) | | Returns a JSON-serializable representation of this <code>QuerySnapshot</code> instance. |
3839

3940
## QuerySnapshot.docs
4041

@@ -127,8 +128,33 @@ forEach(callback: (result: QueryDocumentSnapshot<AppModelType, DbModelType>) =>
127128

128129
void
129130

131+
## QuerySnapshot.fromJSON()
132+
133+
Builds a `QuerySnapshot` instance from a JSON object created by [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson)<!-- -->.
134+
135+
<b>Signature:</b>
136+
137+
```typescript
138+
static fromJSON<AppModelType, DbModelType extends DocumentData = DocumentData>(db: Firestore, json: object): QuerySnapshot<AppModelType, DbModelType> | null;
139+
```
140+
141+
#### Parameters
142+
143+
| Parameter | Type | Description |
144+
| --- | --- | --- |
145+
| db | [Firestore](./firestore_.firestore.md#firestore_class) | |
146+
| json | object | a JSON object represention of a <code>QuerySnapshot</code> instance. |
147+
148+
<b>Returns:</b>
149+
150+
[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<!-- -->&lt;AppModelType, DbModelType&gt; \| null
151+
152+
an instance of [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs.
153+
130154
## QuerySnapshot.toJSON()
131155

156+
Returns a JSON-serializable representation of this `QuerySnapshot` instance.
157+
132158
<b>Signature:</b>
133159

134160
```typescript
@@ -138,3 +164,5 @@ toJSON(): object;
138164

139165
object
140166

167+
a JSON representation of this object.
168+

packages/firestore/src/core/bundle_impl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class BundleConverterImpl implements BundleConverter {
105105
mutableDoc
106106
};
107107
}
108+
108109
toSnapshotVersion(time: ApiTimestamp): SnapshotVersion {
109110
return fromVersion(time);
110111
}

0 commit comments

Comments
 (0)