Class DatastoreClient (2.23.0-rc)

Each RPC normalizes the partition IDs of the keys in its input entities, and always returns entities with keys with normalized partition IDs.

This applies to all keys and entities, including those in values, except keys with both an empty path and an empty or unset partition ID. Normalization of input keys sets the project ID (if not already set) to the project ID from the request.

Equality

Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection> objects compare equal. Objects that compare equal share the same underlying resources.

Performance

Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.

Thread Safety

Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.

Constructors

DatastoreClient(DatastoreClient const &)

Copy and move support

Parameter
NameDescription
DatastoreClient const &

DatastoreClient(DatastoreClient &&)

Copy and move support

Parameter
NameDescription
DatastoreClient &&

DatastoreClient(std::shared_ptr< DatastoreConnection >, Options)

Parameters
NameDescription
connection std::shared_ptr< DatastoreConnection >
opts Options

Operators

operator=(DatastoreClient const &)

Copy and move support

Parameter
NameDescription
DatastoreClient const &
Returns
TypeDescription
DatastoreClient &

operator=(DatastoreClient &&)

Copy and move support

Parameter
NameDescription
DatastoreClient &&
Returns
TypeDescription
DatastoreClient &

Functions

Lookup(std::string const &, google::datastore::v1::ReadOptions const &, std::vector< google::datastore::v1::Key > const &, Options)

Looks up entities by key.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

read_options google::datastore::v1::ReadOptions const &

The options for this lookup request.

keys std::vector< google::datastore::v1::Key > const &

Required. Keys of entities to look up.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::LookupResponse >

the result of the RPC. The response message type (google.datastore.v1.LookupResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

Lookup(google::datastore::v1::LookupRequest const &, Options)

Looks up entities by key.

Parameters
NameDescription
request google::datastore::v1::LookupRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.LookupRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::LookupResponse >

the result of the RPC. The response message type (google.datastore.v1.LookupResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

RunQuery(google::datastore::v1::RunQueryRequest const &, Options)

Queries for entities.

Parameters
NameDescription
request google::datastore::v1::RunQueryRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.RunQueryRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::RunQueryResponse >

the result of the RPC. The response message type (google.datastore.v1.RunQueryResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

RunAggregationQuery(google::datastore::v1::RunAggregationQueryRequest const &, Options)

Runs an aggregation query.

Parameters
NameDescription
request google::datastore::v1::RunAggregationQueryRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.RunAggregationQueryRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::RunAggregationQueryResponse >

the result of the RPC. The response message type (google.datastore.v1.RunAggregationQueryResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

BeginTransaction(std::string const &, Options)

Begins a new transaction.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::BeginTransactionResponse >

the result of the RPC. The response message type (google.datastore.v1.BeginTransactionResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

BeginTransaction(google::datastore::v1::BeginTransactionRequest const &, Options)

Begins a new transaction.

Parameters
NameDescription
request google::datastore::v1::BeginTransactionRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.BeginTransactionRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::BeginTransactionResponse >

the result of the RPC. The response message type (google.datastore.v1.BeginTransactionResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

Commit(std::string const &, google::datastore::v1::CommitRequest::Mode, std::string const &, std::vector< google::datastore::v1::Mutation > const &, Options)

Commits a transaction, optionally creating, deleting or modifying some entities.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

mode google::datastore::v1::CommitRequest::Mode

The type of commit to perform. Defaults to TRANSACTIONAL.

transaction std::string const &

The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to Datastore.BeginTransaction.

mutations std::vector< google::datastore::v1::Mutation > const &

The mutations to perform.
When mode is TRANSACTIONAL, mutations affecting a single entity are applied in order. The following sequences of mutations affecting a single entity are not permitted in a single Commit request:

  • insert followed by insert
  • update followed by insert
  • upsert followed by insert
  • delete followed by update
    When mode is NON_TRANSACTIONAL, no two mutations may affect a single entity.
opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::CommitResponse >

the result of the RPC. The response message type (google.datastore.v1.CommitResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

Commit(std::string const &, google::datastore::v1::CommitRequest::Mode, std::vector< google::datastore::v1::Mutation > const &, Options)

Commits a transaction, optionally creating, deleting or modifying some entities.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

mode google::datastore::v1::CommitRequest::Mode

The type of commit to perform. Defaults to TRANSACTIONAL.

mutations std::vector< google::datastore::v1::Mutation > const &

The mutations to perform.
When mode is TRANSACTIONAL, mutations affecting a single entity are applied in order. The following sequences of mutations affecting a single entity are not permitted in a single Commit request:

  • insert followed by insert
  • update followed by insert
  • upsert followed by insert
  • delete followed by update
    When mode is NON_TRANSACTIONAL, no two mutations may affect a single entity.
opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::CommitResponse >

the result of the RPC. The response message type (google.datastore.v1.CommitResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

Commit(google::datastore::v1::CommitRequest const &, Options)

Commits a transaction, optionally creating, deleting or modifying some entities.

Parameters
NameDescription
request google::datastore::v1::CommitRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.CommitRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::CommitResponse >

the result of the RPC. The response message type (google.datastore.v1.CommitResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

Rollback(std::string const &, std::string const &, Options)

Rolls back a transaction.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

transaction std::string const &

Required. The transaction identifier, returned by a call to Datastore.BeginTransaction.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::RollbackResponse >

the result of the RPC. The response message type (google.datastore.v1.RollbackResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

Rollback(google::datastore::v1::RollbackRequest const &, Options)

Rolls back a transaction.

Parameters
NameDescription
request google::datastore::v1::RollbackRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.RollbackRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::RollbackResponse >

the result of the RPC. The response message type (google.datastore.v1.RollbackResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

AllocateIds(std::string const &, std::vector< google::datastore::v1::Key > const &, Options)

Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

keys std::vector< google::datastore::v1::Key > const &

Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::AllocateIdsResponse >

the result of the RPC. The response message type (google.datastore.v1.AllocateIdsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

AllocateIds(google::datastore::v1::AllocateIdsRequest const &, Options)

Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.

Parameters
NameDescription
request google::datastore::v1::AllocateIdsRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.AllocateIdsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::AllocateIdsResponse >

the result of the RPC. The response message type (google.datastore.v1.AllocateIdsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

ReserveIds(std::string const &, std::vector< google::datastore::v1::Key > const &, Options)

Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.

Parameters
NameDescription
project_id std::string const &

Required. The ID of the project against which to make the request.

keys std::vector< google::datastore::v1::Key > const &

Required. A list of keys with complete key paths whose numeric IDs should not be auto-allocated.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::ReserveIdsResponse >

the result of the RPC. The response message type (google.datastore.v1.ReserveIdsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

ReserveIds(google::datastore::v1::ReserveIdsRequest const &, Options)

Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.

Parameters
NameDescription
request google::datastore::v1::ReserveIdsRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.datastore.v1.ReserveIdsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::datastore::v1::ReserveIdsResponse >

the result of the RPC. The response message type (google.datastore.v1.ReserveIdsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.