firebase::firestore::CollectionReference

#include <collection_reference.h>

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

Summary

Inheritance

Inherits from: firebase::firestore::Query

Constructors and Destructors

CollectionReference()
Creates an invalid CollectionReference that has to be reassigned before it can be used.
CollectionReference(const CollectionReference & other)
Copy constructor.
CollectionReference(CollectionReference && other)
Move constructor.

Public functions

Add(const MapFieldValue & data)
Adds a new document to this collection with the specified data, assigning it a document ID automatically.
Document() const
Returns a DocumentReference that points to a new document with an auto-generated ID within this collection.
Document(const char *document_path) const
Gets a DocumentReference instance that refers to the document at the specified path within this collection.
Document(const std::string & document_path) const
Gets a DocumentReference instance that refers to the document at the specified path within this collection.
Parent() const
Gets a DocumentReference to the document that contains this collection.
id() const
virtual const std::string &
Gets the ID of the referenced collection.
operator=(const CollectionReference & other)
Copy assignment operator.
operator=(CollectionReference && other)
Move assignment operator.
path() const
virtual std::string
Returns the path of this collection (relative to the root of the database) as a slash-separated string.

Public functions

Add

virtual Future< DocumentReference > Add(
  const MapFieldValue & data
)

Adds a new document to this collection with the specified data, assigning it a document ID automatically.

Details
Parameters
data
A map containing the data for the new document.
Returns
A Future that will be resolved with the DocumentReference of the newly created document.

CollectionReference

 CollectionReference()

Creates an invalid CollectionReference that has to be reassigned before it can be used.

Calling any member function on an invalid CollectionReference 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(
  const CollectionReference & other
)

Copy constructor.

CollectionReference can be efficiently copied because it simply refers to a location in the database.

Details
Parameters
other
CollectionReference to copy from.

CollectionReference

 CollectionReference(
  CollectionReference && other
)

Move constructor.

Moving is more efficient than copying for a CollectionReference. After being moved from, a CollectionReference is equivalent to its default-constructed state.

Details
Parameters
other
CollectionReference to move data from.

Document

virtual DocumentReference Document() const 

Returns a DocumentReference that points to a new document with an auto-generated ID within this collection.

Details
Returns
A DocumentReference pointing to the new document.

Document

virtual DocumentReference Document(
  const char *document_path
) const 

Gets a DocumentReference instance that refers to the document at the specified path within this collection.

Details
Parameters
document_path
A slash-separated relative path to a document. The pointer only needs to be valid during this call.
Returns
The DocumentReference instance.

Document

virtual DocumentReference Document(
  const std::string & document_path
) const 

Gets a DocumentReference instance that refers to the document at the specified path within this collection.

Details
Parameters
document_path
A slash-separated relative path to a document.
Returns
The DocumentReference instance.

Parent

virtual DocumentReference Parent() const 

Gets a DocumentReference to the document that contains this collection.

Details
Returns
The DocumentReference that contains this collection if this is a subcollection. If this is a root collection, returns an invalid DocumentReference (DocumentReference::is_valid() will return false).

id

virtual const std::string & id() const 

Gets the ID of the referenced collection.

Details
Returns
The ID as a std::string.

operator=

CollectionReference & operator=(
  const CollectionReference & other
)

Copy assignment operator.

CollectionReference can be efficiently copied because it simply refers to a location in the database.

Details
Parameters
other
CollectionReference to copy from.
Returns
Reference to the destination CollectionReference.

operator=

CollectionReference & operator=(
  CollectionReference && other
)

Move assignment operator.

Moving is more efficient than copying for a CollectionReference. After being moved from, a CollectionReference is equivalent to its default-constructed state.

Details
Parameters
other
CollectionReference to move data from.
Returns
Reference to the destination CollectionReference.

path

virtual std::string path() 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.