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 %}
# CollectionReference class
A `CollectionReference` object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)).
Signature:
```typescript
export declare class CollectionReference extends Query
```
Extends: [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType>
## Properties
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [id](./firestore_lite.collectionreference.md#collectionreferenceid) | | string | The collection's identifier. |
| [parent](./firestore_lite.collectionreference.md#collectionreferenceparent) | | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> \| null | A reference to the containing DocumentReference if this is a subcollection. If this isn't a subcollection, the reference is null. |
| [path](./firestore_lite.collectionreference.md#collectionreferencepath) | | string | A string representing the path of the referenced collection (relative to the root of the database). |
| [type](./firestore_lite.collectionreference.md#collectionreferencetype) | | (not declared) | The type of this Firestore reference. |
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
| [withConverter(converter)](./firestore_lite.collectionreference.md#collectionreferencewithconverter) | | 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_6e783ff) with the returned CollectionReference instance, the provided converter will convert between Firestore data of type NewDbModelType and your custom type NewAppModelType. |
| [withConverter(converter)](./firestore_lite.collectionreference.md#collectionreferencewithconverter) | | Removes the current converter. |
## CollectionReference.id
The collection's identifier.
Signature:
```typescript
get id(): string;
```
## CollectionReference.parent
A reference to the containing `DocumentReference` if this is a subcollection. If this isn't a subcollection, the reference is null.
Signature:
```typescript
get parent(): DocumentReference | null;
```
## CollectionReference.path
A string representing the path of the referenced collection (relative to the root of the database).
Signature:
```typescript
get path(): string;
```
## CollectionReference.type
The type of this Firestore reference.
Signature:
```typescript
readonly type = "collection";
```
## CollectionReference.withConverter()
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_6e783ff) with the returned `CollectionReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`.
Signature:
```typescript
withConverter(converter: FirestoreDataConverter): CollectionReference;
```
#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| converter | [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md#firestoredataconverter_interface)<NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. |
Returns:
[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<NewAppModelType, NewDbModelType>
A `CollectionReference` that uses the provided converter.
## CollectionReference.withConverter()
Removes the current converter.
Signature:
```typescript
withConverter(converter: null): CollectionReference;
```
#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| converter | null | null removes the current converter. |
Returns:
[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)>
A `CollectionReference` that does not use a converter.