Class 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.
Inherited Members
Namespace: Google.Cloud.Firestore
Assembly: Google.Cloud.Firestore.dll
Syntax
public sealed class CollectionReference : Query, IEquatable<Query>, IEquatable<CollectionReference>, IComparable<CollectionReference>
Properties
Id
The final part of the complete collection path; this is the identity of the collection relative to its parent document.
Declaration
public string Id { get; }
Property Value
Type | Description |
---|---|
string |
Parent
The parent document, or null if this is a root collection.
Declaration
public DocumentReference Parent { get; }
Property Value
Type | Description |
---|---|
DocumentReference |
Path
The complete collection path, including project and database ID.
Declaration
public string Path { get; }
Property Value
Type | Description |
---|---|
string |
Methods
AddAsync(object, CancellationToken)
Asynchronously creates a document with the given data in this collection. The document has a randomly generated ID.
Declaration
public Task<DocumentReference> AddAsync(object documentData, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
object | documentData | The data for the document. Must not be null. |
CancellationToken | cancellationToken | A cancellation token to monitor for the asynchronous operation. |
Returns
Type | Description |
---|---|
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)
Declaration
public int CompareTo(CollectionReference other)
Parameters
Type | Name | Description |
---|---|---|
CollectionReference | other |
Returns
Type | Description |
---|---|
int |
Implements
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
.
Declaration
public DocumentReference Document()
Returns
Type | Description |
---|---|
DocumentReference | A DocumentReference to a child document of this collection with a random ID. |
Document(string)
Creates a DocumentReference for a child document of this reference.
Declaration
public DocumentReference Document(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | 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
Type | Description |
---|---|
DocumentReference | A DocumentReference for the specified document. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
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.
Declaration
public IAsyncEnumerable<DocumentReference> ListDocumentsAsync()
Returns
Type | Description |
---|---|
IAsyncEnumerable<DocumentReference> | A lazily-iterated sequence of document references within this collection. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |