voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
33 lines (19 loc) • 1.29 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/firestore](./firestore.md) > [/](./firestore_.md) > [doc](./firestore_.doc_1.md)
## doc() function
Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`<!-- -->.
<b>Signature:</b>
```typescript
export declare function doc<T>(reference: CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| reference | [CollectionReference](./firestore_.collectionreference.md)<!-- --><T> | A reference to a collection. |
| path | string | A slash-separated path to a document. Has to be omitted to use auto-genrated IDs. |
| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. |
<b>Returns:</b>
[DocumentReference](./firestore_.documentreference.md)<!-- --><T>
The `DocumentReference` instance.
## Exceptions
If the final path has an odd number of segments and does not point to a document.