CollectionReference class Stay organized with collections Save and categorize content based on your preferences.
ACollectionReference object can be used for adding documents, getting document references, and querying for documents (usingquery()).
Signature:
exportdeclareclassCollectionReference<AppModelType=DocumentData,DbModelTypeextendsDocumentData=DocumentData>extendsQuery<AppModelType,DbModelType>Extends:Query<AppModelType, DbModelType>
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| id | string | The collection's identifier. | |
| parent | DocumentReference<DocumentData,DocumentData> | null | A reference to the containingDocumentReference if this is a subcollection. If this isn't a subcollection, the reference is null. | |
| path | string | A string representing the path of the referenced collection (relative to the root of the database). | |
| type | (not declared) | The type of this Firestore reference. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| withConverter(converter) | Applies a custom data converter to thisCollectionReference, allowing you to use your own custom model objects with Firestore. When you calladdDoc() with the returnedCollectionReference instance, the provided converter will convert between Firestore data of typeNewDbModelType and your custom typeNewAppModelType. | |
| withConverter(converter) | Removes the current converter. |
CollectionReference.id
The collection's identifier.
Signature:
getid():string;CollectionReference.parent
A reference to the containingDocumentReference if this is a subcollection. If this isn't a subcollection, the reference is null.
Signature:
getparent():DocumentReference<DocumentData,DocumentData>|null;CollectionReference.path
A string representing the path of the referenced collection (relative to the root of the database).
Signature:
getpath():string;CollectionReference.type
The type of this Firestore reference.
Signature:
readonlytype="collection";CollectionReference.withConverter()
Applies a custom data converter to thisCollectionReference, allowing you to use your own custom model objects with Firestore. When you calladdDoc() with the returnedCollectionReference instance, the provided converter will convert between Firestore data of typeNewDbModelType and your custom typeNewAppModelType.
Signature:
withConverter<NewAppModelType,NewDbModelTypeextendsDocumentData=DocumentData>(converter:FirestoreDataConverter<NewAppModelType,NewDbModelType>):CollectionReference<NewAppModelType,NewDbModelType>;Parameters
| Parameter | Type | Description |
|---|---|---|
| converter | FirestoreDataConverter<NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. |
Returns:
CollectionReference<NewAppModelType, NewDbModelType>
ACollectionReference that uses the provided converter.
CollectionReference.withConverter()
Removes the current converter.
Signature:
withConverter(converter:null):CollectionReference<DocumentData,DocumentData>;Parameters
| Parameter | Type | Description |
|---|---|---|
| converter | null | null removes the current converter. |
Returns:
CollectionReference<DocumentData,DocumentData>
ACollectionReference<DocumentData, DocumentData> that does not use a converter.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-19 UTC.