FIRCollectionReference
@interface FIRCollectionReference : FIRQueryA CollectionReference object can be used for adding documents, getting document references,
and querying for documents (using the methods inherited from Query).
-
ID of the referenced collection.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSString *_Nonnull collectionID; -
For subcollections,
parentreturns the containingDocumentReference. For root collections,nilis returned.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) FIRDocumentReference *parent; -
A string containing the slash-separated path to this this
CollectionReference(relative to the root of the database).Declaration
Objective-C
@property (nonatomic, strong, readonly) NSString *_Nonnull path; -
Returns a
DocumentReferencepointing to a new document with an auto-generated ID.Declaration
Objective-C
- (nonnull FIRDocumentReference *)documentWithAutoID;Return Value
A
DocumentReferencepointing to a new document with an auto-generated ID. -
Gets a
DocumentReferencereferring to the document at the specified path, relative to this collection’s own path.Declaration
Objective-C
- (nonnull FIRDocumentReference *)documentWithPath: (nonnull NSString *)documentPath;Parameters
documentPathThe slash-separated relative path of the document for which to get a
DocumentReference.Return Value
The
DocumentReferencefor the specified document path. -
Adds a new document to this collection with the specified data, assigning it a document ID automatically.
Declaration
Objective-C
- (nonnull FIRDocumentReference *)addDocumentWithData: (nonnull NSDictionary<NSString *, id> *)data;Parameters
dataA
Dictionarycontaining the data for the new document.Return Value
A
DocumentReferencepointing to the newly created document. -
Adds a new document to this collection with the specified data, assigning it a document ID automatically.
Declaration
Objective-C
- (nonnull FIRDocumentReference *) addDocumentWithData:(nonnull NSDictionary<NSString *, id> *)data completion:(nullable void (^)(NSError *_Nullable))completion;Parameters
dataA
Dictionarycontaining the data for the new document.completionA 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
DocumentReferencepointing to the newly created document.