Reference documentation and code samples for the Cloud Datastore Client class Operation.
Run lookups and queries and commit changes.
This class is used by Google\Cloud\Datastore\Google\Cloud\Datastore\DatastoreClient and Google\Cloud\Datastore\Google\Cloud\Datastore\Transaction and is not intended to be used directly.
Examples are omitted for brevity. Detailed usage examples can be found in Google\Cloud\Datastore\Google\Cloud\Datastore\DatastoreClient and Google\Cloud\Datastore\Google\Cloud\Datastore\Transaction .
Namespace
Google \ Cloud \ DatastoreMethods
__construct
Create an operation
connection
Google\Cloud\Datastore\Connection\ConnectionInterface
A connection to Google Cloud Platform's Datastore API.
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
Create a single Key instance
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
Create multiple keys with the same configuration.
When inserting multiple entities, creating a set of keys at once can be useful. By defining the Key's kind and any ancestors up front, and allowing Cloud Datastore to allocate IDs, you can be sure that your entity identity and ancestry are correct and that there will be no collisions during the insert operation.
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
Create an entity
This method does not execute any service requests.
Entities are created with a Datastore Key, or by specifying a Kind. Kinds are only allowed for insert operations. For any other case, you must specify a named key. If a kind is given, an ID will be automatically allocated for the entity upon insert. Additionally, if your entity requires a complex key elementPath, you must create the key separately.
In certain cases, you may want to create your own entity types.
Google Cloud PHP supports custom types implementing Google\Cloud\Datastore\Google\Cloud\Datastore\EntityInterface
. If the name of an EntityInterface
implementation is given in the options array, an
instance of that class will be returned instead of Google\Cloud\Datastore\Google\Cloud\Datastore\Entity
.
key
Google\Cloud\Datastore\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 Google\Cloud\Datastore\Google\Cloud\Datastore\EntityInterface . Defaults to Google\Cloud\Datastore\Google\Cloud\Datastore\Entity .
↳ excludeFromIndexes
array
A list of entity keys to exclude from datastore indexes.
Google\Cloud\Datastore\EntityInterface
beginTransaction
Begin a Datastore Transaction.
transactionOptions
options
array
Configuration options.
string
allocateIds
Allocate available IDs to a set of keys
Keys MUST be in an incomplete state (i.e. including a kind but not an ID or name in their final pathElement).
This method will execute a service request.
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 Google\Cloud\Datastore\Google\Cloud\Datastore\EntityInterface . If an array is given, it must be an associative array, where the key is a Kind and the value must implement Google\Cloud\Datastore\Google\Cloud\Datastore\EntityInterface . Defaults to Google\Cloud\Datastore\Google\Cloud\Datastore\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
Google\Cloud\Datastore\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 Google\Cloud\Datastore\Google\Cloud\Datastore\EntityInterface . Defaults to Google\Cloud\Datastore\Google\Cloud\Datastore\Entity .
↳ readConsistency
↳ databaseId
string
ID of the database to which the entities belong.
↳ readTime
Timestamp
Reads entities as they were at the given timestamp.
Google\Cloud\Datastore\EntityIterator<\google\cloud\datastore\entityinterface>
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< Google\Cloud\Datastore\EntityInterface
>
A list of entities
array< Google\Cloud\Datastore\EntityInterface
>
mutation
Enqueue a mutation
A mutation is a change to the datastore. Create, Update and Delete are examples of mutations, while Read is not.
Google Cloud Datastore supports multiple mutations in a single API call, subject to the limits of the service. Adding mutations separately from committing the changes allows you to create complex operations, both inside a transaction and not.
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< Google\Cloud\Datastore\EntityInterface
>
the entities to be updated or upserted.
allowOverwrite
bool
If true
, entities may be overwritten. Defaults to false
.
void