Class CollectionReference (2.5.0)

public sealed class CollectionReference : Query, IEquatable<Query>, IEquatable<CollectionReference>, IComparable<CollectionReference>

A reference to a collection in a Firestore database. The existence of this object does not imply that the collection currently exists in storage.

Inheritance

Object > Query > CollectionReference

Namespace

Google.Cloud.Firestore

Assembly

Google.Cloud.Firestore.dll

Properties

Id

public string Id { get; }

The final part of the complete collection path; this is the identity of the collection relative to its parent document.

Property Value
TypeDescription
String

Parent

public DocumentReference Parent { get; }

The parent document, or null if this is a root collection.

Property Value
TypeDescription
DocumentReference

Path

public string Path { get; }

The complete collection path, including project and database ID.

Property Value
TypeDescription
String

Methods

AddAsync(Object, CancellationToken)

public Task<DocumentReference> AddAsync(object documentData, CancellationToken cancellationToken = default(CancellationToken))

Asynchronously creates a document with the given data in this collection. The document has a randomly generated ID.

Parameters
NameDescription
documentDataObject

The data for the document. Must not be null.

cancellationTokenCancellationToken

A cancellation token to monitor for the asynchronous operation.

Returns
TypeDescription
Task<DocumentReference>

The reference for the newly-created document.

Remarks

If the WriteResult for the operation is required, use CreateAsync(Object, CancellationToken) instead of this method.

CompareTo(CollectionReference)

public int CompareTo(CollectionReference other)
Parameter
NameDescription
otherCollectionReference
Returns
TypeDescription
Int32

Document()

public DocumentReference Document()

Creates a DocumentReference for a direct child document of this collection with a random ID. This performs no server-side operations; it only generates the appropriate DocumentReference.

Returns
TypeDescription
DocumentReference

A DocumentReference to a child document of this collection with a random ID.

Document(String)

public DocumentReference Document(string path)

Creates a DocumentReference for a child document of this reference.

Parameter
NameDescription
pathString

The path to the document, relative to this collection. Must not be null, and must contain an odd number of slash-separated path elements.

Returns
TypeDescription
DocumentReference

A DocumentReference for the specified document.

GetHashCode()

public override int GetHashCode()
Returns
TypeDescription
Int32
Overrides

ListDocumentsAsync()

public IAsyncEnumerable<DocumentReference> ListDocumentsAsync()

Lists the documents in this collection. The results include documents which don't exist in their own right, but which have nested documents which do exist.

Returns
TypeDescription
IAsyncEnumerable<DocumentReference>

A lazily-iterated sequence of document references within this collection.

ToString()

public override string ToString()
Returns
TypeDescription
String
Overrides