Firestore v1 API - Class FirestoreClientImpl (3.5.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
NameDescription
grpcClientFirestoreFirestoreClient

The underlying gRPC client.

settingsFirestoreSettings

The base FirestoreSettings used within this client.

loggerILogger

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
TypeDescription
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
TypeDescription
FirestoreFirestoreClient
Overrides

LocationsClient

public override LocationsClient LocationsClient { get; }

The LocationsClient associated with this client.

Property Value
TypeDescription
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
NameDescription
requestBatchGetDocumentsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestBatchWriteRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestBatchWriteRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestBeginTransactionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
BeginTransactionResponse

The RPC response.

Overrides

BeginTransactionAsync(BeginTransactionRequest, CallSettings)

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

Starts a new transaction.

Parameters
NameDescription
requestBeginTransactionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCommitRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCommitRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCreateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Document

The RPC response.

Overrides

CreateDocumentAsync(CreateDocumentRequest, CallSettings)

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

Creates a new document.

Parameters
NameDescription
requestCreateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskDocument

A Task containing the RPC response.

Overrides

DeleteDocument(DeleteDocumentRequest, CallSettings)

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

Deletes a document.

Parameters
NameDescription
requestDeleteDocumentRequest

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

callSettingsCallSettings

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
NameDescription
requestDeleteDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Document

The RPC response.

Overrides

GetDocumentAsync(GetDocumentRequest, CallSettings)

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

Gets a single document.

Parameters
NameDescription
requestGetDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestListCollectionIdsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestListCollectionIdsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestListDocumentsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestListDocumentsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
callSettingsCallSettings

If not null, applies overrides to this RPC call.

streamingSettingsBidirectionalStreamingSettings

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

Returns
TypeDescription
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
NameDescription
requestPartitionQueryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestPartitionQueryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestRollbackRequest

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

callSettingsCallSettings

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
NameDescription
requestRollbackRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestRunAggregationQueryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
FirestoreClientRunAggregationQueryStream

The server stream.

Overrides

RunQuery(RunQueryRequest, CallSettings)

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

Runs a query.

Parameters
NameDescription
requestRunQueryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
FirestoreClientRunQueryStream

The server stream.

Overrides

UpdateDocument(UpdateDocumentRequest, CallSettings)

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

Updates or inserts a document.

Parameters
NameDescription
requestUpdateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Document

The RPC response.

Overrides

UpdateDocumentAsync(UpdateDocumentRequest, CallSettings)

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

Updates or inserts a document.

Parameters
NameDescription
requestUpdateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
callSettingsCallSettings

If not null, applies overrides to this RPC call.

streamingSettingsBidirectionalStreamingSettings

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

Returns
TypeDescription
FirestoreClientWriteStream

The client-server stream.

Overrides