docs-devsite/firestore_lite_pipelines.documentreference.md
Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist.
<b>Signature:</b>
export declare class DocumentReference<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
| Property | Modifiers | Type | Description |
|---|---|---|---|
| converter | FirestoreDataConverter<!-- --><AppModelType, DbModelType> | null | If provided, the <code>FirestoreDataConverter</code> associated with this instance. | |
| firestore | Firestore | The Firestore instance the document is in. This is useful for performing transactions, for example. | |
| id | string | The document's identifier within its collection. | |
| parent | CollectionReference<!-- --><AppModelType, DbModelType> | The collection this <code>DocumentReference</code> belongs to. | |
| path | string | A string representing the path of the referenced document (relative to the root of the database). | |
| type | (not declared) | The type of this Firestore reference. |
| Method | Modifiers | Description |
|---|---|---|
| fromJSON(firestore, json) | <code>static</code> | Builds a <code>DocumentReference</code> instance from a JSON object created by DocumentReference.toJSON()<!-- -->. |
| fromJSON(firestore, json, converter) | <code>static</code> | Builds a <code>DocumentReference</code> instance from a JSON object created by DocumentReference.toJSON()<!-- -->. |
| toJSON() | Returns a JSON-serializable representation of this <code>DocumentReference</code> instance. | |
| withConverter(converter) | 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()<!-- -->, 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>. | |
| withConverter(converter) | Removes the current converter. |
If provided, the FirestoreDataConverter associated with this instance.
<b>Signature:</b>
readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;
The Firestore instance the document is in. This is useful for performing transactions, for example.
<b>Signature:</b>
readonly firestore: Firestore;
The document's identifier within its collection.
<b>Signature:</b>
get id(): string;
The collection this DocumentReference belongs to.
<b>Signature:</b>
get parent(): CollectionReference<AppModelType, DbModelType>;
A string representing the path of the referenced document (relative to the root of the database).
<b>Signature:</b>
get path(): string;
The type of this Firestore reference.
<b>Signature:</b>
readonly type = "document";
Builds a DocumentReference instance from a JSON object created by DocumentReference.toJSON()<!-- -->.
<b>Signature:</b>
static fromJSON(firestore: Firestore, json: object): DocumentReference;
| Parameter | Type | Description |
|---|---|---|
| firestore | Firestore | The Firestore instance the snapshot should be loaded for. |
| json | object | a JSON object represention of a <code>DocumentReference</code> instance |
<b>Returns:</b>
an instance of DocumentReference if the JSON object could be parsed. Throws a FirestoreError if an error occurs.
Builds a DocumentReference instance from a JSON object created by DocumentReference.toJSON()<!-- -->.
<b>Signature:</b>
static fromJSON<NewAppModelType = DocumentData, NewDbModelType extends DocumentData = DocumentData>(firestore: Firestore, json: object, converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
| Parameter | Type | Description |
|---|---|---|
| firestore | Firestore | The Firestore instance the snapshot should be loaded for. |
| json | object | a JSON object represention of a <code>DocumentReference</code> instance |
| converter | FirestoreDataConverter<!-- --><NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. |
<b>Returns:</b>
DocumentReference<!-- --><NewAppModelType, NewDbModelType>
an instance of DocumentReference if the JSON object could be parsed. Throws a FirestoreError if an error occurs.
Returns a JSON-serializable representation of this DocumentReference instance.
<b>Signature:</b>
toJSON(): object;
<b>Returns:</b>
object
a JSON representation of this object.
Applies a custom data converter to this DocumentReference<!-- -->, allowing you to use your own custom model objects with Firestore. When you call setDoc()<!-- -->, getDoc()<!-- -->, etc. with the returned DocumentReference instance, the provided converter will convert between Firestore data of type NewDbModelType and your custom type NewAppModelType<!-- -->.
<b>Signature:</b>
withConverter<NewAppModelType, NewDbModelType extends DocumentData = DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
| Parameter | Type | Description |
|---|---|---|
| converter | FirestoreDataConverter<!-- --><NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. |
<b>Returns:</b>
DocumentReference<!-- --><NewAppModelType, NewDbModelType>
A DocumentReference that uses the provided converter.
Removes the current converter.
<b>Signature:</b>
withConverter(converter: null): DocumentReference<DocumentData, DocumentData>;
| Parameter | Type | Description |
|---|---|---|
| converter | null | <code>null</code> removes the current converter. |
<b>Returns:</b>
DocumentReference<!-- --><DocumentData<!-- -->, DocumentData<!-- -->>
A DocumentReference<DocumentData, DocumentData> that does not use a converter.