public sealed class CollectionReference : Query, IEquatable<Query>, IEquatable<CollectionReference>, IComparable<CollectionReference>
Reference documentation and code samples for the Firestore API 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.
Namespace
Google.Cloud.FirestoreAssembly
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 | |
---|---|
Type | Description |
string |
Parent
public DocumentReference Parent { get; }
The parent document, or null if this is a root collection.
Property Value | |
---|---|
Type | Description |
DocumentReference |
Path
public string Path { get; }
The complete collection path, including project and database ID.
Property Value | |
---|---|
Type | Description |
string |
Methods
AddAsync(object, CancellationToken)
public Task<DocumentReference> AddAsync(object documentData, CancellationToken cancellationToken = default)
Asynchronously creates a document with the given data in this collection. The document has a randomly generated ID.
Parameters | |
---|---|
Name | Description |
documentData | object The data for the document. Must not be null. |
cancellationToken | CancellationToken A cancellation token to monitor for the asynchronous operation. |
Returns | |
---|---|
Type | Description |
TaskDocumentReference | The reference for the newly-created document. |
If the WriteResult for the operation is required, use CreateAsync(object, CancellationToken) instead of this method.
CompareTo(CollectionReference)
public int CompareTo(CollectionReference other)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Parameter | |
---|---|
Name | Description |
other | CollectionReference An object to compare with this instance. |
Returns | |
---|---|
Type | Description |
int | A value that indicates the relative order of the objects being compared. The return value has these meanings: Meaning Less than zero This instance precedes Zero This instance occurs in the same position in the sort order as Greater than zero This instance follows |
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 | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
path | string 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()
public override int GetHashCode()
Serves as the default hash function.
Returns | |
---|---|
Type | Description |
int | A hash code for the current object. |
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 | |
---|---|
Type | Description |
IAsyncEnumerableDocumentReference | A lazily-iterated sequence of document references within this collection. |
ToString()
public override string ToString()
Returns a string that represents the current object.
Returns | |
---|---|
Type | Description |
string | A string that represents the current object. |