Go to console

A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using the methods inherited from Query).

Index

Constructors

Private constructor

Properties

firestore

firestore: Firestore

The Firestore for the Firestore database (useful for performing transactions, etc.).

id

id: string

The collection's identifier.

parent

parent: DocumentReference | null

A reference to the containing DocumentReference if this is a subcollection. If this isn't a subcollection, the reference is null.

path

path: string

A string representing the path of the referenced collection (relative to the root of the database).

Methods

add

  • add(data: DocumentData): Promise<DocumentReference>
  • Add a new document to this collection with the specified data, assigning it a document ID automatically.

    Parameters

    • data: DocumentData

      An Object containing the data for the new document.

    Returns Promise<DocumentReference>

    A Promise resolved with a DocumentReference pointing to the newly created document after it has been written to the backend.

doc

  • doc(documentPath?: string): DocumentReference
  • Get a DocumentReference for the document within the collection at the specified path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference.

    Parameters