Home > @firebase/firestore > / > collection
collection() function
Gets a CollectionReference
instance that refers to the collection at the specified absolute path.
Signature:
export declare function collection(firestore: FirebaseFirestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
Parameters
Parameter | Type | Description |
---|---|---|
firestore | FirebaseFirestore | A reference to the root Firestore instance. |
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.