Firestore v1 API - Class FirestoreClientImpl (3.6.0)

public sealed class FirestoreClientImpl : FirestoreClient

Reference documentation and code samples for the Firestore v1 API class FirestoreClientImpl.

Firestore client wrapper implementation, for convenient use.

Inheritance

object > FirestoreClient > FirestoreClientImpl

Namespace

Google.Cloud.Firestore.V1

Assembly

Google.Cloud.Firestore.V1.dll

Remarks

The Cloud Firestore service.

Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL document database that simplifies storing, syncing, and querying data for your mobile, web, and IoT apps at global scale. Its client libraries provide live synchronization and offline support, while its security features and integrations with Firebase and Google Cloud Platform accelerate building truly serverless apps.

Constructors

FirestoreClientImpl(FirestoreClient, FirestoreSettings, ILogger)

public FirestoreClientImpl(Firestore.FirestoreClient grpcClient, FirestoreSettings settings, ILogger logger)

Constructs a client wrapper for the Firestore service, with the specified gRPC client and settings.

Parameters
Name Description
grpcClient FirestoreFirestoreClient

The underlying gRPC client.

settings FirestoreSettings

The base FirestoreSettings used within this client.

logger ILogger

Optional ILogger to use within this client.

Fields

ResourcePrefixHeader

[Obsolete("This header is obsolete; x-goog-request-params should now be used instead. This constant will be removed in a future version")]
public const string ResourcePrefixHeader = "google-cloud-resource-prefix"

The name of the header used for efficiently routing requests.

Field Value
Type Description
string
Remarks

This should be set to the database resource name ("projects/{projectId}/databases/{databaseId}") for any RPC. For non-streaming calls, FirestoreClientImpl performs this automatically. This cannot be performed automatically for streaming calls due to the separation between initializing the stream and sending requests, so client code should set the value in a CallSettings. Typically this is performed with either the FromHeader(string, string) factory method or the WithHeader(CallSettings, string, string) extension method.

Properties

GrpcClient

public override Firestore.FirestoreClient GrpcClient { get; }

The underlying gRPC Firestore client

Property Value
Type Description
FirestoreFirestoreClient
Overrides

LocationsClient

public override LocationsClient LocationsClient { get; }

The LocationsClient associated with this client.

Property Value
Type Description
LocationsClient
Overrides

Methods

BatchGetDocuments(BatchGetDocumentsRequest, CallSettings)

public override FirestoreClient.BatchGetDocumentsStream BatchGetDocuments(BatchGetDocumentsRequest request, CallSettings callSettings = null)

Gets multiple documents.

Documents returned by this method are not guaranteed to be returned in the same order that they were requested.

Parameters
Name Description
request BatchGetDocumentsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
FirestoreClientBatchGetDocumentsStream

The server stream.

Overrides

BatchWrite(BatchWriteRequest, CallSettings)

public override BatchWriteResponse BatchWrite(BatchWriteRequest request, CallSettings callSettings = null)

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write.

If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.Commit] instead.

Parameters
Name Description
request BatchWriteRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
BatchWriteResponse

The RPC response.

Overrides

BatchWriteAsync(BatchWriteRequest, CallSettings)

public override Task<BatchWriteResponse> BatchWriteAsync(BatchWriteRequest request, CallSettings callSettings = null)

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write.

If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.Commit] instead.

Parameters
Name Description
request BatchWriteRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskBatchWriteResponse

A Task containing the RPC response.

Overrides

BeginTransaction(BeginTransactionRequest, CallSettings)

public override BeginTransactionResponse BeginTransaction(BeginTransactionRequest request, CallSettings callSettings = null)

Starts a new transaction.

Parameters
Name Description
request BeginTransactionRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
BeginTransactionResponse

The RPC response.

Overrides

BeginTransactionAsync(BeginTransactionRequest, CallSettings)

public override Task<BeginTransactionResponse> BeginTransactionAsync(BeginTransactionRequest request, CallSettings callSettings = null)

Starts a new transaction.

Parameters
Name Description
request BeginTransactionRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskBeginTransactionResponse

A Task containing the RPC response.

Overrides

Commit(CommitRequest, CallSettings)

public override CommitResponse Commit(CommitRequest request, CallSettings callSettings = null)

Commits a transaction, while optionally updating documents.

Parameters
Name Description
request CommitRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CommitResponse

The RPC response.

Overrides

CommitAsync(CommitRequest, CallSettings)

public override Task<CommitResponse> CommitAsync(CommitRequest request, CallSettings callSettings = null)

Commits a transaction, while optionally updating documents.

Parameters
Name Description
request CommitRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskCommitResponse

A Task containing the RPC response.

Overrides

CreateDocument(CreateDocumentRequest, CallSettings)

public override Document CreateDocument(CreateDocumentRequest request, CallSettings callSettings = null)

Creates a new document.

Parameters
Name Description
request CreateDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Document

The RPC response.

Overrides

CreateDocumentAsync(CreateDocumentRequest, CallSettings)

public override Task<Document> CreateDocumentAsync(CreateDocumentRequest request, CallSettings callSettings = null)

Creates a new document.

Parameters
Name Description
request CreateDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDocument

A Task containing the RPC response.

Overrides

DeleteDocument(DeleteDocumentRequest, CallSettings)

public override void DeleteDocument(DeleteDocumentRequest request, CallSettings callSettings = null)

Deletes a document.

Parameters
Name Description
request DeleteDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Overrides

DeleteDocumentAsync(DeleteDocumentRequest, CallSettings)

public override Task DeleteDocumentAsync(DeleteDocumentRequest request, CallSettings callSettings = null)

Deletes a document.

Parameters
Name Description
request DeleteDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Overrides

GetDocument(GetDocumentRequest, CallSettings)

public override Document GetDocument(GetDocumentRequest request, CallSettings callSettings = null)

Gets a single document.

Parameters
Name Description
request GetDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Document

The RPC response.

Overrides

GetDocumentAsync(GetDocumentRequest, CallSettings)

public override Task<Document> GetDocumentAsync(GetDocumentRequest request, CallSettings callSettings = null)

Gets a single document.

Parameters
Name Description
request GetDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDocument

A Task containing the RPC response.

Overrides

ListCollectionIds(ListCollectionIdsRequest, CallSettings)

public override PagedEnumerable<ListCollectionIdsResponse, string> ListCollectionIds(ListCollectionIdsRequest request, CallSettings callSettings = null)

Lists all the collection IDs underneath a document.

Parameters
Name Description
request ListCollectionIdsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListCollectionIdsResponsestring

A pageable sequence of string resources.

Overrides

ListCollectionIdsAsync(ListCollectionIdsRequest, CallSettings)

public override PagedAsyncEnumerable<ListCollectionIdsResponse, string> ListCollectionIdsAsync(ListCollectionIdsRequest request, CallSettings callSettings = null)

Lists all the collection IDs underneath a document.

Parameters
Name Description
request ListCollectionIdsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListCollectionIdsResponsestring

A pageable asynchronous sequence of string resources.

Overrides

ListDocuments(ListDocumentsRequest, CallSettings)

public override PagedEnumerable<ListDocumentsResponse, Document> ListDocuments(ListDocumentsRequest request, CallSettings callSettings = null)

Lists documents.

Parameters
Name Description
request ListDocumentsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListDocumentsResponseDocument

A pageable sequence of Document resources.

Overrides

ListDocumentsAsync(ListDocumentsRequest, CallSettings)

public override PagedAsyncEnumerable<ListDocumentsResponse, Document> ListDocumentsAsync(ListDocumentsRequest request, CallSettings callSettings = null)

Lists documents.

Parameters
Name Description
request ListDocumentsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListDocumentsResponseDocument

A pageable asynchronous sequence of Document resources.

Overrides

Listen(CallSettings, BidirectionalStreamingSettings)

public override FirestoreClient.ListenStream Listen(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Listens to changes. This method is only available via gRPC or WebChannel (not REST).

Parameters
Name Description
callSettings CallSettings

If not null, applies overrides to this RPC call.

streamingSettings BidirectionalStreamingSettings

If not null, applies streaming overrides to this RPC call.

Returns
Type Description
FirestoreClientListenStream

The client-server stream.

Overrides

PartitionQuery(PartitionQueryRequest, CallSettings)

public override PagedEnumerable<PartitionQueryResponse, Cursor> PartitionQuery(PartitionQueryRequest request, CallSettings callSettings = null)

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.

Parameters
Name Description
request PartitionQueryRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerablePartitionQueryResponseCursor

A pageable sequence of Cursor resources.

Overrides

PartitionQueryAsync(PartitionQueryRequest, CallSettings)

public override PagedAsyncEnumerable<PartitionQueryResponse, Cursor> PartitionQueryAsync(PartitionQueryRequest request, CallSettings callSettings = null)

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.

Parameters
Name Description
request PartitionQueryRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerablePartitionQueryResponseCursor

A pageable asynchronous sequence of Cursor resources.

Overrides

Rollback(RollbackRequest, CallSettings)

public override void Rollback(RollbackRequest request, CallSettings callSettings = null)

Rolls back a transaction.

Parameters
Name Description
request RollbackRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Overrides

RollbackAsync(RollbackRequest, CallSettings)

public override Task RollbackAsync(RollbackRequest request, CallSettings callSettings = null)

Rolls back a transaction.

Parameters
Name Description
request RollbackRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Overrides

RunAggregationQuery(RunAggregationQueryRequest, CallSettings)

public override FirestoreClient.RunAggregationQueryStream RunAggregationQuery(RunAggregationQueryRequest request, CallSettings callSettings = null)

Runs an aggregation query.

Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API allows running an aggregation to produce a series of [AggregationResult][google.firestore.v1.AggregationResult] server-side.

High-Level Example:

-- Return the number of documents in table given a filter.
SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
Parameters
Name Description
request RunAggregationQueryRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
FirestoreClientRunAggregationQueryStream

The server stream.

Overrides

RunQuery(RunQueryRequest, CallSettings)

public override FirestoreClient.RunQueryStream RunQuery(RunQueryRequest request, CallSettings callSettings = null)

Runs a query.

Parameters
Name Description
request RunQueryRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
FirestoreClientRunQueryStream

The server stream.

Overrides

UpdateDocument(UpdateDocumentRequest, CallSettings)

public override Document UpdateDocument(UpdateDocumentRequest request, CallSettings callSettings = null)

Updates or inserts a document.

Parameters
Name Description
request UpdateDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Document

The RPC response.

Overrides

UpdateDocumentAsync(UpdateDocumentRequest, CallSettings)

public override Task<Document> UpdateDocumentAsync(UpdateDocumentRequest request, CallSettings callSettings = null)

Updates or inserts a document.

Parameters
Name Description
request UpdateDocumentRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDocument

A Task containing the RPC response.

Overrides

Write(CallSettings, BidirectionalStreamingSettings)

public override FirestoreClient.WriteStream Write(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).

Parameters
Name Description
callSettings CallSettings

If not null, applies overrides to this RPC call.

streamingSettings BidirectionalStreamingSettings

If not null, applies streaming overrides to this RPC call.

Returns
Type Description
FirestoreClientWriteStream

The client-server stream.

Overrides