A CollectionReference object can be used for adding documents, getting document references,
and querying for documents (using the methods inherited from Query).
A Dictionary containing the data for the new document.
completion
A block to execute once the document has been successfully written to
the server. This block will not be called while the client is offline, though local
changes will be visible immediately.
Return Value
A DocumentReference pointing to the newly created document.
[[["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-03-11 UTC."],[],[],null,["# FirebaseFirestore Framework Reference\n\nFIRCollectionReference\n======================\n\n\n @interface FIRCollectionReference : ../Classes/FIRQuery.html\n\nA `CollectionReference` object can be used for adding documents, getting document references,\nand querying for documents (using the methods inherited from `Query`).\n- `\n ``\n ``\n `\n\n ### [collectionID](#/c:objc(cs)FIRCollectionReference(py)collectionID)\n\n `\n ` \n ID of the referenced collection. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) NSString *_Nonnull collectionID;\n\n- `\n ``\n ``\n `\n\n ### [parent](#/c:objc(cs)FIRCollectionReference(py)parent)\n\n `\n ` \n For subcollections, `parent` returns the containing `DocumentReference`. For root collections,\n `nil` is returned. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly, nullable) ../Classes/FIRDocumentReference.html *parent;\n\n- `\n ``\n ``\n `\n\n ### [path](#/c:objc(cs)FIRCollectionReference(py)path)\n\n `\n ` \n A string containing the slash-separated path to this this `CollectionReference` (relative to the\n root of the database). \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) NSString *_Nonnull path;\n\n- `\n ``\n ``\n `\n\n ### [-documentWithAutoID](#/c:objc(cs)FIRCollectionReference(im)documentWithAutoID)\n\n `\n ` \n Returns a `DocumentReference` pointing to a new document with an auto-generated ID. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull ../Classes/FIRDocumentReference.html *)documentWithAutoID;\n\n #### Return Value\n\n A `DocumentReference` pointing to a new document with an auto-generated ID.\n- `\n ``\n ``\n `\n\n ### [-documentWithPath:](#/c:objc(cs)FIRCollectionReference(im)documentWithPath:)\n\n `\n ` \n Gets a `DocumentReference` referring to the document at the specified path, relative to this\n collection's own path. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull ../Classes/FIRDocumentReference.html *)documentWithPath:\n (nonnull NSString *)documentPath;\n\n #### Parameters\n\n |----------------------|-------------------------------------------------------------------------------------------|\n | ` `*documentPath*` ` | The slash-separated relative path of the document for which to get a `DocumentReference`. |\n\n #### Return Value\n\n The `DocumentReference` for the specified document path.\n- `\n ``\n ``\n `\n\n ### [-addDocumentWithData:](#/c:objc(cs)FIRCollectionReference(im)addDocumentWithData:)\n\n `\n ` \n Adds a new document to this collection with the specified data, assigning it a document ID\n automatically. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull ../Classes/FIRDocumentReference.html *)addDocumentWithData:\n (nonnull NSDictionary\u003cNSString *, id\u003e *)data;\n\n #### Parameters\n\n |--------------|----------------------------------------------------------|\n | ` `*data*` ` | A `Dictionary` containing the data for the new document. |\n\n #### Return Value\n\n A `DocumentReference` pointing to the newly created document.\n- `\n ``\n ``\n `\n\n ### [-addDocumentWithData:completion:](#/c:objc(cs)FIRCollectionReference(im)addDocumentWithData:completion:)\n\n `\n ` \n Adds a new document to this collection with the specified data, assigning it a document ID\n automatically. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull ../Classes/FIRDocumentReference.html *)\n addDocumentWithData:(nonnull NSDictionary\u003cNSString *, id\u003e *)data\n completion:(nullable void (^)(NSError *_Nullable))completion;\n\n #### Parameters\n\n |--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*data*` ` | A `Dictionary` containing the data for the new document. |\n | ` `*completion*` ` | A block to execute once the document has been successfully written to the server. This block will not be called while the client is offline, though local changes will be visible immediately. |\n\n #### Return Value\n\n A `DocumentReference` pointing to the newly created document."]]