Reference documentation and code samples for the Cloud Datastore Client class Operation.
Run lookups and queries and commit changes.
This class is used by DatastoreClient and Transaction and is not intended to be used directly.
Examples are omitted for brevity. Detailed usage examples can be found in DatastoreClient and Transaction .
Namespace
Google \ Cloud \ DatastoreMethods
__construct
Create an operation
connection
Connection\ConnectionInterface
A connection to Google Cloud Platform's Datastore API. This object is created by DatastoreClient, and should not be instantiated outside of this client.
projectId
string
The Google Cloud Platform project ID.
namespaceId
string
The namespace to use for all service requests.
entityMapper
databaseId
string
ID of the database to which the entities belong.
key
See also:
kind
string
The kind.
identifier
string|int
[optional] The ID or name.
options
array
Configuration Options
↳ identifierType
string
If omitted, type will be determined internally. In cases where any ambiguity can be expected (i.e. if you want to create keys with name
but your values may pass PHP's is_numeric()
check), this value may be explicitly set using Key::TYPE_ID
or Key::TYPE_NAME
.
↳ databaseId
string
ID of the database to which the entities belong.
keys
See also:
kind
string
The kind to use in the final path element.
options
array
Configuration Options
↳ ancestors
↳ number
int
The number of keys to generate.
↳ id
string|int
The ID for the last pathElement.
↳ name
string
The Name for the last pathElement.
entity
See also:
key
Key
|string|null
[optional] The key used to identify the record, or a string $kind. The key may be null only if the entity will be used as an embedded entity within another entity. Attempting to use keyless entities as root entities will result in error.
entity
array
[optional] The data to fill the entity with.
options
array
Configuration Options
↳ className
string
If set, the given class will be returned. Value must be the name of a class implementing EntityInterface . Defaults to Entity .
↳ excludeFromIndexes
array
A list of entity keys to exclude from datastore indexes.
EntityInterface
beginTransaction
Begin a Datastore Transaction.
transactionOptions
options
array
Configuration options.
string
allocateIds
See also:
keys
options
array
[optional] Configuration Options.
lookup
Lookup records by key
keys
options
array
Configuration Options
↳ readConsistency
↳ transaction
string
The transaction ID, if the query should be run in a transaction.
↳ className
string|array
If a string, the given class will be returned. Value must be the name of a class implementing EntityInterface . If an array is given, it must be an associative array, where the key is a Kind and the value must implement EntityInterface . Defaults to Entity .
↳ sort
bool
If set to true, results in each set will be sorted to match the order given in $keys. Defaults to false
.
↳ databaseId
string
ID of the database to which the entities belong.
↳ readTime
Timestamp
Reads entities as they were at the given timestamp.
array
runQuery
Run a query and return entities
query
Query\QueryInterface
The query object.
options
array
Configuration Options
↳ transaction
string
The transaction ID, if the query should be run in a transaction.
↳ className
string
If set, the given class will be returned. Value must be the name of a class implementing EntityInterface . Defaults to Entity .
↳ readConsistency
↳ databaseId
string
ID of the database to which the entities belong.
↳ readTime
Timestamp
Reads entities as they were at the given timestamp.
↳ explainMetrics
ExplainMetrics
The ExplainMetrics object for query stats. V1\ExplainOptions} </xref
runAggregationQuery
Run an aggregation query and return aggregated results.
runQueryObj
options
array
Configuration Options
↳ transaction
string
The transaction ID, if the query should be run in a transaction.
↳ readConsistency
↳ databaseId
string
ID of the database to which the entities belong.
↳ readTime
Timestamp
Reads entities as they were at the given timestamp.
commit
Commit all mutations
Calling this method will end the operation (and close the transaction, if one is specified).
mutations
options
array
Configuration Options
↳ transaction
string
The transaction ID, if the query should be run in a transaction.
↳ databaseId
string
ID of the database to which the entities belong.
array
allocateIdsToEntities
Patch any incomplete keys in the given array of entities
Any incomplete keys will be allocated an ID. Named keys in the input will remain unchanged.
entities
array< EntityInterface
>
A list of entities
array< EntityInterface
>
mutation
See also:
operation
string
The operation to execute. "Insert", "Upsert", "Update" or "Delete".
input
type
string
The type of the input array.
baseVersion
string
[optional] The version of the entity that this mutation is being applied to. If this does not match the current version on the server, the mutation conflicts.
array
rollback
Roll back a transaction
transactionId
string
The transaction to roll back
void
checkOverwrite
Check whether an update or upsert operation may proceed safely
entities
array< EntityInterface
>
the entities to be updated or upserted.
allowOverwrite
bool
If true
, entities may be overwritten. Defaults to
* false
.
void