firebase:: firestore:: CollectionReference
#include <collection_reference.h>
ACollectionReference can be used for adding documents, getting document references, and querying for documents (using the methods inherited fromQuery).
Summary
Note: Firestore classes are not meant to be subclassed except for use in test mocks. Subclassing is not supported in production code and new SDK releases may break code that does so.
Inheritance
Inherits from:firebase::firestore::QueryConstructors and Destructors | |
|---|---|
CollectionReference()Creates an invalidCollectionReference that has to be reassigned before it can be used. | |
CollectionReference(constCollectionReference & other)Copy constructor. | |
CollectionReference(CollectionReference && other)Move constructor. |
Public functions | |
|---|---|
Add(constMapFieldValue & data) | virtualFuture<DocumentReference >Adds a new document to this collection with the specified data, assigning it a document ID automatically. |
Document() const | virtualDocumentReferenceReturns aDocumentReference that points to a new document with an auto-generated ID within this collection. |
Document(const char *document_path) const | virtualDocumentReferenceGets aDocumentReference instance that refers to the document at the specified path within this collection. |
Document(const std::string & document_path) const | virtualDocumentReferenceGets aDocumentReference instance that refers to the document at the specified path within this collection. |
Parent() const | virtualDocumentReferenceGets aDocumentReference to the document that contains this collection. |
id() const | virtual const std::string &Gets the ID of the referenced collection. |
operator=(constCollectionReference & other) | Copy assignment operator. |
operator=(CollectionReference && other) | Move assignment operator. |
path() const | virtual std::stringReturns the path of this collection (relative to the root of the database) as a slash-separated string. |
Public functions
Add
virtualFuture<DocumentReference>Add(constMapFieldValue&data)
Adds a new document to this collection with the specified data, assigning it a document ID automatically.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | AFuture that will be resolved with theDocumentReference of the newly created document. |
CollectionReference
CollectionReference()
Creates an invalidCollectionReference that has to be reassigned before it can be used.
Calling any member function on an invalidCollectionReference will be a no-op. If the function returns a value, it will return a zero, empty, or invalid value, depending on the type of the value.
CollectionReference
CollectionReference(constCollectionReference&other)
Copy constructor.
CollectionReference can be efficiently copied because it simply refers to a location in the database.
| Details | |||
|---|---|---|---|
| Parameters |
|
CollectionReference
CollectionReference(CollectionReference&&other)
Move constructor.
Moving is more efficient than copying for aCollectionReference. After being moved from, aCollectionReference is equivalent to its default-constructed state.
| Details | |||
|---|---|---|---|
| Parameters |
|
Document
virtualDocumentReferenceDocument()const
Returns aDocumentReference that points to a new document with an auto-generated ID within this collection.
| Details | |
|---|---|
| Returns | ADocumentReference pointing to the new document. |
Document
virtualDocumentReferenceDocument(constchar*document_path)const
Gets aDocumentReference instance that refers to the document at the specified path within this collection.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | TheDocumentReference instance. |
Document
virtualDocumentReferenceDocument(conststd::string&document_path)const
Gets aDocumentReference instance that refers to the document at the specified path within this collection.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | TheDocumentReference instance. |
Parent
virtualDocumentReferenceParent()const
Gets aDocumentReference to the document that contains this collection.
| Details | |
|---|---|
| Returns | TheDocumentReference that contains this collection if this is a subcollection. If this is a root collection, returns an invalidDocumentReference ( DocumentReference::is_valid() will return false). |
id
virtualconststd::string&id()const
Gets the ID of the referenced collection.
| Details | |
|---|---|
| Returns | The ID as a std::string. |
operator=
CollectionReference&operator=(constCollectionReference&other)
Copy assignment operator.
CollectionReference can be efficiently copied because it simply refers to a location in the database.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Reference to the destination CollectionReference. |
operator=
CollectionReference&operator=(CollectionReference&&other)
Move assignment operator.
Moving is more efficient than copying for aCollectionReference. After being moved from, aCollectionReference is equivalent to its default-constructed state.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Reference to the destination CollectionReference. |
path
virtualstd::stringpath()const
Returns the path of this collection (relative to the root of the database) as a slash-separated string.
| Details | |
|---|---|
| Returns | The path as a std::string. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-23 UTC.