A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using the methods inherited from [Query]Query).
letcollectionRef=firestore.collection('col');collectionRef.add({foo:'bar'}).then(documentReference=>{console.log(`Added document with name: ${documentReference.id}`);});
Retrieves the list of documents in this collection.
The document references returned may include references to "missing documents", i.e. document locations that have no document present but which contain subcollections with documents. Attempting to read such a document reference (e.g. via .get() or .onSnapshot()) will return a DocumentSnapshot whose .exists property is false.
{Promise<DocumentReference[]>} The list of documents in this collection.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class CollectionReference (7.11.0)\n\nVersion latestkeyboard_arrow_down\n\n- [7.11.0 (latest)](/nodejs/docs/reference/firestore/latest/firestore/collectionreference)\n- [7.9.0](/nodejs/docs/reference/firestore/7.9.0/firestore/collectionreference)\n- [7.7.0](/nodejs/docs/reference/firestore/7.7.0/firestore/collectionreference)\n- [7.6.0](/nodejs/docs/reference/firestore/7.6.0/firestore/collectionreference)\n- [7.5.0](/nodejs/docs/reference/firestore/7.5.0/firestore/collectionreference)\n- [7.4.0](/nodejs/docs/reference/firestore/7.4.0/firestore/collectionreference)\n- [7.3.1](/nodejs/docs/reference/firestore/7.3.1/firestore/collectionreference)\n- [7.2.0](/nodejs/docs/reference/firestore/7.2.0/firestore/collectionreference)\n- [7.1.0](/nodejs/docs/reference/firestore/7.1.0/firestore/collectionreference)\n- [6.4.1](/nodejs/docs/reference/firestore/6.4.1/firestore/collectionreference)\n- [6.3.0](/nodejs/docs/reference/firestore/6.3.0/firestore/collectionreference)\n- [6.0.0](/nodejs/docs/reference/firestore/6.0.0/firestore/collectionreference)\n- [5.0.2](/nodejs/docs/reference/firestore/5.0.2/firestore/collectionreference)\n- [4.15.1](/nodejs/docs/reference/firestore/4.15.1/firestore/collectionreference)\n- [4.14.2](/nodejs/docs/reference/firestore/4.14.2/firestore/collectionreference)\n- [4.9.8](/nodejs/docs/reference/firestore/4.9.8/firestore/collectionreference) \nA CollectionReference object can be used for adding documents, getting document references, and querying for documents (using the methods inherited from \\[Query\\][Query](/nodejs/docs/reference/firestore/latest/firestore/query)).\n\nCollectionReference Query \n\nInheritance\n-----------\n\n[Query](/nodejs/docs/reference/firestore/latest/firestore/query)\\\u003cAppModelType, DbModelType\\\u003e \\\u003e CollectionReference\n\nPackage\n-------\n\n[@google-cloud/firestore](../overview.html)\n\nConstructors\n------------\n\n### (constructor)(firestore, path, converter)\n\n constructor(firestore: Firestore, path: ResourcePath, converter?: firestore.FirestoreDataConverter\u003cAppModelType, DbModelType\u003e);\n\nConstructs a new instance of the `CollectionReference` class\n\nProperties\n----------\n\n### id\n\n get id(): string;\n\nThe last path element of the referenced collection.\n\n{string} CollectionReference#id\n**Example** \n\n\n let collectionRef = firestore.collection('col/doc/subcollection');\n console.log(`ID of the subcollection: ${collectionRef.id}`);\n\n### parent\n\n get parent(): DocumentReference | null;\n\nA reference to the containing Document if this is a subcollection, else null.\n\n{DocumentReference\\|null} CollectionReference#parent\n**Example** \n\n\n let collectionRef = firestore.collection('col/doc/subcollection');\n let documentRef = collectionRef.parent;\n console.log(`Parent name: ${documentRef.path}`);\n\n### path\n\n get path(): string;\n\nA string representing the path of the referenced collection (relative to the root of the database).\n\n{string} CollectionReference#path\n**Example** \n\n\n let collectionRef = firestore.collection('col/doc/subcollection');\n console.log(`Path of the subcollection: ${collectionRef.path}`);\n\nMethods\n-------\n\n### add(data)\n\n add(data: firestore.WithFieldValue\u003cAppModelType\u003e): Promise\u003cDocumentReference\u003cAppModelType, DbModelType\u003e\u003e;\n\nAdd a new document to this collection with the specified data, assigning it a document ID automatically.\n\n**Example** \n\n\n let collectionRef = firestore.collection('col');\n collectionRef.add({foo: 'bar'}).then(documentReference =\u003e {\n console.log(`Added document with name: ${documentReference.id}`);\n });\n\n### doc()\n\n doc(): DocumentReference\u003cAppModelType, DbModelType\u003e;\n\n### doc(documentPath)\n\n doc(documentPath: string): DocumentReference\u003cAppModelType, DbModelType\u003e;\n\n### isEqual(other)\n\n isEqual(other: firestore.CollectionReference\u003cAppModelType, DbModelType\u003e): boolean;\n\nReturns true if this `CollectionReference` is equal to the provided value.\n\n### listDocuments()\n\n listDocuments(): Promise\u003cArray\u003cDocumentReference\u003cAppModelType, DbModelType\u003e\u003e\u003e;\n\nRetrieves the list of documents in this collection.\n\nThe document references returned may include references to \"missing documents\", i.e. document locations that have no document present but which contain subcollections with documents. Attempting to read such a document reference (e.g. via `.get()` or `.onSnapshot()`) will return a `DocumentSnapshot` whose `.exists` property is false.\n\n{Promise\\\u003cDocumentReference\\[\\]\\\u003e} The list of documents in this collection.\n\n**Example** \n\n\n let collectionRef = firestore.collection('col');\n\n return collectionRef.listDocuments().then(documentRefs =\u003e {\n return firestore.getAll(...documentRefs);\n }).then(documentSnapshots =\u003e {\n for (let documentSnapshot of documentSnapshots) {\n if (documentSnapshot.exists) {\n console.log(`Found document with data: ${documentSnapshot.id}`);\n } else {\n console.log(`Found missing document: ${documentSnapshot.id}`);\n }\n }\n });\n\n### withConverter(converter)\n\n withConverter(converter: null): CollectionReference;\n\n### withConverter(converter)\n\n withConverter\u003cNewAppModelType, NewDbModelType extends firestore.DocumentData = firestore.DocumentData\u003e(converter: firestore.FirestoreDataConverter\u003cNewAppModelType, NewDbModelType\u003e): CollectionReference\u003cNewAppModelType, NewDbModelType\u003e;"]]