Reference documentation and code samples for the Cloud Firestore V1 API class Google::Cloud::Firestore::V1::Firestore::Client.
Client for the Firestore service.
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.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the Firestore Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all Firestore clients ::Google::Cloud::Firestore::V1::Firestore::Client.configure do |config| config.timeout = 10.0 end
#batch_get_documents
def batch_get_documents(request, options = nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>
def batch_get_documents(database: nil, documents: nil, mask: nil, transaction: nil, new_transaction: nil, read_time: nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>
Gets multiple documents.
Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
def batch_get_documents(request, options = nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>
batch_get_documents
via a request object, either of type
BatchGetDocumentsRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_get_documents(database: nil, documents: nil, mask: nil, transaction: nil, new_transaction: nil, read_time: nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>
batch_get_documents
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
database (::String) — Required. The database name. In the format:
projects/{project_id}/databases/{database_id}
. -
documents (::Array<::String>) — The names of the documents to retrieve. In the format:
projects/{project_id}/databases/{database_id}/documents/{document_path}
. The request will fail if any of the document is not a child resource of the givendatabase
. Duplicate names will be elided. -
mask (::Google::Cloud::Firestore::V1::DocumentMask, ::Hash) — The fields to return. If not set, returns all fields.
If a document has a field that is not present in this mask, that field will not be returned in the response.
- transaction (::String) — Reads documents in a transaction.
- new_transaction (::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash) — Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream.
-
read_time (::Google::Protobuf::Timestamp, ::Hash) — Reads documents as they were at the given time.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
- (response, operation) — Access the result along with the RPC operation
- response (::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>)
- operation (::GRPC::ActiveCall::Operation)
- (::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::BatchGetDocumentsRequest.new # Call the batch_get_documents method to start streaming. output = client.batch_get_documents request # The returned object is a streamed enumerable yielding elements of type # ::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse output.each do |current_response| p current_response end
#batch_write
def batch_write(request, options = nil) -> ::Google::Cloud::Firestore::V1::BatchWriteResponse
def batch_write(database: nil, writes: nil, labels: nil) -> ::Google::Cloud::Firestore::V1::BatchWriteResponse
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 for the success status of each write.
If you require an atomically applied set of writes, use Commit instead.
def batch_write(request, options = nil) -> ::Google::Cloud::Firestore::V1::BatchWriteResponse
batch_write
via a request object, either of type
BatchWriteRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::BatchWriteRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_write(database: nil, writes: nil, labels: nil) -> ::Google::Cloud::Firestore::V1::BatchWriteResponse
batch_write
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
database (::String) — Required. The database name. In the format:
projects/{project_id}/databases/{database_id}
. -
writes (::Array<::Google::Cloud::Firestore::V1::Write, ::Hash>) — The writes to apply.
Method does not apply writes atomically and does not guarantee ordering. Each write succeeds or fails independently. You cannot write to the same document more than once per request.
- labels (::Hash{::String => ::String}) — Labels associated with this batch write.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::BatchWriteResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::BatchWriteRequest.new # Call the batch_write method. result = client.batch_write request # The returned object is of type Google::Cloud::Firestore::V1::BatchWriteResponse. p result
#begin_transaction
def begin_transaction(request, options = nil) -> ::Google::Cloud::Firestore::V1::BeginTransactionResponse
def begin_transaction(database: nil, options: nil) -> ::Google::Cloud::Firestore::V1::BeginTransactionResponse
Starts a new transaction.
def begin_transaction(request, options = nil) -> ::Google::Cloud::Firestore::V1::BeginTransactionResponse
begin_transaction
via a request object, either of type
BeginTransactionRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::BeginTransactionRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def begin_transaction(database: nil, options: nil) -> ::Google::Cloud::Firestore::V1::BeginTransactionResponse
begin_transaction
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
database (::String) — Required. The database name. In the format:
projects/{project_id}/databases/{database_id}
. - options (::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash) — The options for the transaction. Defaults to a read-write transaction.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::BeginTransactionResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::BeginTransactionRequest.new # Call the begin_transaction method. result = client.begin_transaction request # The returned object is of type Google::Cloud::Firestore::V1::BeginTransactionResponse. p result
#commit
def commit(request, options = nil) -> ::Google::Cloud::Firestore::V1::CommitResponse
def commit(database: nil, writes: nil, transaction: nil) -> ::Google::Cloud::Firestore::V1::CommitResponse
Commits a transaction, while optionally updating documents.
def commit(request, options = nil) -> ::Google::Cloud::Firestore::V1::CommitResponse
commit
via a request object, either of type
CommitRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::CommitRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def commit(database: nil, writes: nil, transaction: nil) -> ::Google::Cloud::Firestore::V1::CommitResponse
commit
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
database (::String) — Required. The database name. In the format:
projects/{project_id}/databases/{database_id}
. -
writes (::Array<::Google::Cloud::Firestore::V1::Write, ::Hash>) — The writes to apply.
Always executed atomically and in order.
- transaction (::String) — If set, applies all writes in this transaction, and commits it.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::CommitResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::CommitRequest.new # Call the commit method. result = client.commit request # The returned object is of type Google::Cloud::Firestore::V1::CommitResponse. p result
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the Firestore Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#create_document
def create_document(request, options = nil) -> ::Google::Cloud::Firestore::V1::Document
def create_document(parent: nil, collection_id: nil, document_id: nil, document: nil, mask: nil) -> ::Google::Cloud::Firestore::V1::Document
Creates a new document.
def create_document(request, options = nil) -> ::Google::Cloud::Firestore::V1::Document
create_document
via a request object, either of type
CreateDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::CreateDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_document(parent: nil, collection_id: nil, document_id: nil, document: nil, mask: nil) -> ::Google::Cloud::Firestore::V1::Document
create_document
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent resource. For example:
projects/{project_id}/databases/{database_id}/documents
orprojects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}
-
collection_id (::String) — Required. The collection ID, relative to
parent
, to list. For example:chatrooms
. -
document_id (::String) — The client-assigned document ID to use for this document.
Optional. If not specified, an ID will be assigned by the service.
-
document (::Google::Cloud::Firestore::V1::Document, ::Hash) — Required. The document to create.
name
must not be set. -
mask (::Google::Cloud::Firestore::V1::DocumentMask, ::Hash) — The fields to return. If not set, returns all fields.
If the document has a field that is not present in this mask, that field will not be returned in the response.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::CreateDocumentRequest.new # Call the create_document method. result = client.create_document request # The returned object is of type Google::Cloud::Firestore::V1::Document. p result
#delete_document
def delete_document(request, options = nil) -> ::Google::Protobuf::Empty
def delete_document(name: nil, current_document: nil) -> ::Google::Protobuf::Empty
Deletes a document.
def delete_document(request, options = nil) -> ::Google::Protobuf::Empty
delete_document
via a request object, either of type
DeleteDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::DeleteDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_document(name: nil, current_document: nil) -> ::Google::Protobuf::Empty
delete_document
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The resource name of the Document to delete. In the format:
projects/{project_id}/databases/{database_id}/documents/{document_path}
. - current_document (::Google::Cloud::Firestore::V1::Precondition, ::Hash) — An optional precondition on the document. The request will fail if this is set and not met by the target document.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::DeleteDocumentRequest.new # Call the delete_document method. result = client.delete_document request # The returned object is of type Google::Protobuf::Empty. p result
#get_document
def get_document(request, options = nil) -> ::Google::Cloud::Firestore::V1::Document
def get_document(name: nil, mask: nil, transaction: nil, read_time: nil) -> ::Google::Cloud::Firestore::V1::Document
Gets a single document.
def get_document(request, options = nil) -> ::Google::Cloud::Firestore::V1::Document
get_document
via a request object, either of type
GetDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::GetDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_document(name: nil, mask: nil, transaction: nil, read_time: nil) -> ::Google::Cloud::Firestore::V1::Document
get_document
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The resource name of the Document to get. In the format:
projects/{project_id}/databases/{database_id}/documents/{document_path}
. -
mask (::Google::Cloud::Firestore::V1::DocumentMask, ::Hash) — The fields to return. If not set, returns all fields.
If the document has a field that is not present in this mask, that field will not be returned in the response.
- transaction (::String) — Reads the document in a transaction.
-
read_time (::Google::Protobuf::Timestamp, ::Hash) — Reads the version of the document at the given time.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::GetDocumentRequest.new # Call the get_document method. result = client.get_document request # The returned object is of type Google::Cloud::Firestore::V1::Document. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new Firestore client object.
- (config) — Configure the Firestore client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Firestore::V1::Firestore::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Firestore::V1::Firestore::Client.new do |config| config.timeout = 10.0 end
#list_collection_ids
def list_collection_ids(request, options = nil) -> ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse
def list_collection_ids(parent: nil, page_size: nil, page_token: nil, read_time: nil) -> ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse
Lists all the collection IDs underneath a document.
def list_collection_ids(request, options = nil) -> ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse
list_collection_ids
via a request object, either of type
ListCollectionIdsRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::ListCollectionIdsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_collection_ids(parent: nil, page_size: nil, page_token: nil, read_time: nil) -> ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse
list_collection_ids
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent document. In the format:
projects/{project_id}/databases/{database_id}/documents/{document_path}
. For example:projects/my-project/databases/my-database/documents/chatrooms/my-chatroom
- page_size (::Integer) — The maximum number of results to return.
- page_token (::String) — A page token. Must be a value from ListCollectionIdsResponse.
-
read_time (::Google::Protobuf::Timestamp, ::Hash) — Reads documents as they were at the given time.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::ListCollectionIdsResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::ListCollectionIdsRequest.new # Call the list_collection_ids method. result = client.list_collection_ids request # The returned object is of type Google::Cloud::Firestore::V1::ListCollectionIdsResponse. p result
#list_documents
def list_documents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>
def list_documents(parent: nil, collection_id: nil, page_size: nil, page_token: nil, order_by: nil, mask: nil, transaction: nil, read_time: nil, show_missing: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>
Lists documents.
def list_documents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>
list_documents
via a request object, either of type
ListDocumentsRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::ListDocumentsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_documents(parent: nil, collection_id: nil, page_size: nil, page_token: nil, order_by: nil, mask: nil, transaction: nil, read_time: nil, show_missing: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>
list_documents
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent resource name. In the format:
projects/{project_id}/databases/{database_id}/documents
orprojects/{project_id}/databases/{database_id}/documents/{document_path}
.For example:
projects/my-project/databases/my-database/documents
orprojects/my-project/databases/my-database/documents/chatrooms/my-chatroom
-
collection_id (::String) — Optional. The collection ID, relative to
parent
, to list.For example:
chatrooms
ormessages
.This is optional, and when not provided, Firestore will list documents from all collections under the provided
parent
. -
page_size (::Integer) — Optional. The maximum number of documents to return in a single response.
Firestore may return fewer than this value.
-
page_token (::String) — Optional. A page token, received from a previous
ListDocuments
response.Provide this to retrieve the subsequent page. When paginating, all other parameters (with the exception of
page_size
) must match the values set in the request that generated the page token. -
order_by (::String) — Optional. The optional ordering of the documents to return.
For example:
priority desc, __name__ desc
.This mirrors the
ORDER BY
used in Firestore queries but in a string representation. When absent, documents are ordered based on__name__ ASC
. -
mask (::Google::Cloud::Firestore::V1::DocumentMask, ::Hash) — Optional. The fields to return. If not set, returns all fields.
If a document has a field that is not present in this mask, that field will not be returned in the response.
- transaction (::String) — Perform the read as part of an already active transaction.
-
read_time (::Google::Protobuf::Timestamp, ::Hash) — Perform the read at the provided time.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
-
show_missing (::Boolean) — If the list should show missing documents.
A document is missing if it does not exist, but there are sub-documents nested underneath it. When true, such missing documents will be returned with a key but will not have fields,
create_time
, orupdate_time
set.Requests with
show_missing
may not specifywhere
ororder_by
.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::ListDocumentsRequest.new # Call the list_documents method. result = client.list_documents request # The returned object is of type Gapic::PagedEnumerable. You can iterate # over elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::Firestore::V1::Document. p item end
#listen
def listen(request, options = nil) { |response, operation| ... } -> ::Enumerable<::Google::Cloud::Firestore::V1::ListenResponse>
Listens to changes. This method is only available via gRPC or WebChannel (not REST).
- request (::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Firestore::V1::ListenRequest, ::Hash>) — An enumerable of ListenRequest instances.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
- (response, operation) — Access the result along with the RPC operation
- response (::Enumerable<::Google::Cloud::Firestore::V1::ListenResponse>)
- operation (::GRPC::ActiveCall::Operation)
- (::Enumerable<::Google::Cloud::Firestore::V1::ListenResponse>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create an input stream. input = Gapic::StreamInput.new # Call the listen method to start streaming. output = client.listen input # Send requests on the stream. For each request object, set fields by # passing keyword arguments. Be sure to close the stream when done. input << Google::Cloud::Firestore::V1::ListenRequest.new input << Google::Cloud::Firestore::V1::ListenRequest.new input.close # The returned object is a streamed enumerable yielding elements of type # ::Google::Cloud::Firestore::V1::ListenResponse output.each do |current_response| p current_response end
#location_client
def location_client() -> Google::Cloud::Location::Locations::Client
Get the associated client for mix-in of the Locations.
- (Google::Cloud::Location::Locations::Client)
#partition_query
def partition_query(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>
def partition_query(parent: nil, structured_query: nil, partition_count: nil, page_token: nil, page_size: nil, read_time: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>
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.
def partition_query(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>
partition_query
via a request object, either of type
PartitionQueryRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::PartitionQueryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def partition_query(parent: nil, structured_query: nil, partition_count: nil, page_token: nil, page_size: nil, read_time: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>
partition_query
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent resource name. In the format:
projects/{project_id}/databases/{database_id}/documents
. Document resource names are not supported; only database resource names can be specified. - structured_query (::Google::Cloud::Firestore::V1::StructuredQuery, ::Hash) — A structured query. Query must specify collection with all descendants and be ordered by name ascending. Other filters, order bys, limits, offsets, and start/end cursors are not supported.
-
partition_count (::Integer) — The desired maximum number of partition points.
The partitions may be returned across multiple pages of results.
The number must be positive. The actual number of partitions
returned may be fewer.
For example, this may be set to one fewer than the number of parallel queries to be run, or in running a data pipeline job, one fewer than the number of workers or compute instances available.
-
page_token (::String) — The
next_page_token
value returned from a previous call to PartitionQuery that may be used to get an additional set of results. There are no ordering guarantees between sets of results. Thus, using multiple sets of results will require merging the different result sets.For example, two subsequent calls using a page_token may return:
- cursor B, cursor M, cursor Q
- cursor A, cursor U, cursor W
To obtain a complete result set ordered with respect to the results of the query supplied to PartitionQuery, the results sets should be merged: cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
-
page_size (::Integer) — The maximum number of partitions to return in this call, subject to
partition_count
.For example, if
partition_count
= 10 andpage_size
= 8, the first call to PartitionQuery will return up to 8 partitions and anext_page_token
if more results exist. A second call to PartitionQuery will return up to 2 partitions, to complete the total of 10 specified inpartition_count
. -
read_time (::Google::Protobuf::Timestamp, ::Hash) — Reads documents as they were at the given time.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::PartitionQueryRequest.new # Call the partition_query method. result = client.partition_query request # The returned object is of type Gapic::PagedEnumerable. You can iterate # over elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::Firestore::V1::Cursor. p item end
#rollback
def rollback(request, options = nil) -> ::Google::Protobuf::Empty
def rollback(database: nil, transaction: nil) -> ::Google::Protobuf::Empty
Rolls back a transaction.
def rollback(request, options = nil) -> ::Google::Protobuf::Empty
rollback
via a request object, either of type
RollbackRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::RollbackRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def rollback(database: nil, transaction: nil) -> ::Google::Protobuf::Empty
rollback
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
database (::String) — Required. The database name. In the format:
projects/{project_id}/databases/{database_id}
. - transaction (::String) — Required. The transaction to roll back.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::RollbackRequest.new # Call the rollback method. result = client.rollback request # The returned object is of type Google::Protobuf::Empty. p result
#run_aggregation_query
def run_aggregation_query(request, options = nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>
def run_aggregation_query(parent: nil, structured_aggregation_query: nil, transaction: nil, new_transaction: nil, read_time: nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>
Runs an aggregation query.
Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of 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 );
def run_aggregation_query(request, options = nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>
run_aggregation_query
via a request object, either of type
RunAggregationQueryRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::RunAggregationQueryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def run_aggregation_query(parent: nil, structured_aggregation_query: nil, transaction: nil, new_transaction: nil, read_time: nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>
run_aggregation_query
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent resource name. In the format:
projects/{project_id}/databases/{database_id}/documents
orprojects/{project_id}/databases/{database_id}/documents/{document_path}
. For example:projects/my-project/databases/my-database/documents
orprojects/my-project/databases/my-database/documents/chatrooms/my-chatroom
- structured_aggregation_query (::Google::Cloud::Firestore::V1::StructuredAggregationQuery, ::Hash) — An aggregation query.
-
transaction (::String) — Run the aggregation within an already active transaction.
The value here is the opaque transaction ID to execute the query in.
-
new_transaction (::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash) — Starts a new transaction as part of the query, defaulting to read-only.
The new transaction ID will be returned as the first response in the stream.
-
read_time (::Google::Protobuf::Timestamp, ::Hash) — Executes the query at the given timestamp.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
- (response, operation) — Access the result along with the RPC operation
- response (::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>)
- operation (::GRPC::ActiveCall::Operation)
- (::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::RunAggregationQueryRequest.new # Call the run_aggregation_query method to start streaming. output = client.run_aggregation_query request # The returned object is a streamed enumerable yielding elements of type # ::Google::Cloud::Firestore::V1::RunAggregationQueryResponse output.each do |current_response| p current_response end
#run_query
def run_query(request, options = nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>
def run_query(parent: nil, structured_query: nil, transaction: nil, new_transaction: nil, read_time: nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>
Runs a query.
def run_query(request, options = nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>
run_query
via a request object, either of type
RunQueryRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::RunQueryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def run_query(parent: nil, structured_query: nil, transaction: nil, new_transaction: nil, read_time: nil) -> ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>
run_query
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent resource name. In the format:
projects/{project_id}/databases/{database_id}/documents
orprojects/{project_id}/databases/{database_id}/documents/{document_path}
. For example:projects/my-project/databases/my-database/documents
orprojects/my-project/databases/my-database/documents/chatrooms/my-chatroom
- structured_query (::Google::Cloud::Firestore::V1::StructuredQuery, ::Hash) — A structured query.
-
transaction (::String) — Run the query within an already active transaction.
The value here is the opaque transaction ID to execute the query in.
- new_transaction (::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash) — Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream.
-
read_time (::Google::Protobuf::Timestamp, ::Hash) — Reads documents as they were at the given time.
This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
- (response, operation) — Access the result along with the RPC operation
- response (::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>)
- operation (::GRPC::ActiveCall::Operation)
- (::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::RunQueryRequest.new # Call the run_query method to start streaming. output = client.run_query request # The returned object is a streamed enumerable yielding elements of type # ::Google::Cloud::Firestore::V1::RunQueryResponse output.each do |current_response| p current_response end
#universe_domain
def universe_domain() -> String
The effective universe domain
- (String)
#update_document
def update_document(request, options = nil) -> ::Google::Cloud::Firestore::V1::Document
def update_document(document: nil, update_mask: nil, mask: nil, current_document: nil) -> ::Google::Cloud::Firestore::V1::Document
Updates or inserts a document.
def update_document(request, options = nil) -> ::Google::Cloud::Firestore::V1::Document
update_document
via a request object, either of type
UpdateDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Firestore::V1::UpdateDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_document(document: nil, update_mask: nil, mask: nil, current_document: nil) -> ::Google::Cloud::Firestore::V1::Document
update_document
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Firestore::V1::Document, ::Hash) — Required. The updated document. Creates the document if it does not already exist.
-
update_mask (::Google::Cloud::Firestore::V1::DocumentMask, ::Hash) — The fields to update.
None of the field paths in the mask may contain a reserved name.
If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server.
-
mask (::Google::Cloud::Firestore::V1::DocumentMask, ::Hash) — The fields to return. If not set, returns all fields.
If the document has a field that is not present in this mask, that field will not be returned in the response.
- current_document (::Google::Cloud::Firestore::V1::Precondition, ::Hash) — An optional precondition on the document. The request will fail if this is set and not met by the target document.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Firestore::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Firestore::V1::UpdateDocumentRequest.new # Call the update_document method. result = client.update_document request # The returned object is of type Google::Cloud::Firestore::V1::Document. p result
#write
def write(request, options = nil) { |response, operation| ... } -> ::Enumerable<::Google::Cloud::Firestore::V1::WriteResponse>
Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
- request (::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Firestore::V1::WriteRequest, ::Hash>) — An enumerable of WriteRequest instances.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
- (response, operation) — Access the result along with the RPC operation
- response (::Enumerable<::Google::Cloud::Firestore::V1::WriteResponse>)
- operation (::GRPC::ActiveCall::Operation)
- (::Enumerable<::Google::Cloud::Firestore::V1::WriteResponse>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/firestore/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Firestore::V1::Firestore::Client.new # Create an input stream. input = Gapic::StreamInput.new # Call the write method to start streaming. output = client.write input # Send requests on the stream. For each request object, set fields by # passing keyword arguments. Be sure to close the stream when done. input << Google::Cloud::Firestore::V1::WriteRequest.new input << Google::Cloud::Firestore::V1::WriteRequest.new input.close # The returned object is a streamed enumerable yielding elements of type # ::Google::Cloud::Firestore::V1::WriteResponse output.each do |current_response| p current_response end