Home > @firebase/firestore > / > collection
collection() function
Gets a CollectionReference
instance that refers to a subcollection of reference
at the the specified relative path.
Signature:
export declare function collection(reference: CollectionReference<unknown>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
Parameters
Parameter | Type | Description |
---|---|---|
reference | CollectionReference<unknown> | A reference to a collection. |
path | string | A slash-separated path to a collection. |
pathSegments | string[] | Additional path segments to apply relative to the first argument. |
Returns:
CollectionReference<DocumentData>
The CollectionReference
instance.
Exceptions
If the final path has an even number of segments and does not point to a collection.