The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/firestore > / > CollectionReference

CollectionReference class

A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using query()).

Signature:

export declare class CollectionReference<T = DocumentData> extends Query<T> 

Extends: Query<T>

Properties

Property Modifiers Type Description
id string The collection's identifier.
parent DocumentReference<DocumentData> | null A reference to the containing DocumentReference 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 this CollectionReference, allowing you to use your own custom model objects with Firestore. When you call addDoc() with the returned CollectionReference instance, the provided converter will convert between Firestore data and your custom type U.
withConverter(converter) Removes the current converter.