Classes
Datastore
Idiomatic class for interacting with Cloud Datastore. Uses the lower-level DatastoreClient class under the hood.
In addition to the constructor options shown here, the Datastore class constructor accepts the same options accepted by DatastoreClient.
The Datastore Emulator
Make sure you have the gcloud SDK installed, then run:
$ gcloud beta emulators datastore start --no-legacy
You will see the following printed:
\[datastore\] API endpoint: http://localhost:8005 \[datastore\] If you are using a library that supports the DATASTORE\_EMULATOR\_HOST environment variable, run: \[datastore\] \[datastore\] export DATASTORE\_EMULATOR\_HOST=localhost:8005 \[datastore\] \[datastore\] Dev App Server is now running.
Set that environment variable and your localhost Datastore will automatically be used. You can also pass this address in manually with apiEndpoint
.
Additionally, DATASTORE_PROJECT_ID
is recognized. If you have this set, you don't need to provide a projectId
.
DatastoreAdminClient
Google Cloud Datastore Admin API
The Datastore Admin API provides several admin services for Cloud Datastore.
----------------------------------------------------------------------------- ## Concepts
Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
Operation: An Operation represents work being performed in the background.
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a combination of kinds and namespaces (either or both of which may be all).
----------------------------------------------------------------------------- ## Services
# Export/Import
The Export/Import service provides the ability to copy all or a subset of entities to/from Google Cloud Storage.
Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It is not restricted to the export source project. It is possible to export from one project and then import into another.
Exported data can also be loaded into Google BigQuery for analysis.
Exports and imports are performed asynchronously. An Operation resource is created for each export/import. The state (including any errors encountered) of the export/import may be queried via the Operation resource.
# Index
The index service manages Cloud Datastore composite indexes.
Index creation and deletion are performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.
# Operation
The Operations collection provides a record of actions performed for the specified project (including any operations in progress). Operations are not created directly but through calls on other collections or resources.
An operation that is not yet done may be cancelled. The request to cancel is asynchronous and the operation may continue to run for some time after the request to cancel is made.
An operation that is done may be deleted so that it is no longer listed as part of the Operation collection.
ListOperations returns all pending operations, but not completed operations.
Operations are created by service DatastoreAdmin, but are accessed via service google.longrunning.Operations. v1
DatastoreClient
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.
v1
DatastoreRequest
Handle logic for Datastore API operations. Handles request logic for Datastore.
Creates requests to the Datastore endpoint. Designed to be inherited by the Datastore and Transaction classes.
Index
Key
Build a Datastore Key object.
Query
Build a Query object.
**Queries are built with {module:datastore#createQuery} and .**
Transaction
A transaction is a set of Datastore operations on one or more entities. Each transaction is guaranteed to be atomic, which means that transactions are never partially applied. Either all of the operations in the transaction are applied, or none of them are applied.
Interfaces
BooleanObject
DatastoreOptions
EntityProtoReduceAccumulator
EntityProtoReduceData
ExportEntitiesConfig
ImportEntitiesConfig
KeyToLegacyUrlSafeCallback
LongRunningCallback
TransactionOptions
Variables
v1
v1: any
Type Aliases
Entity
export declare type Entity = any;
InsertCallback
export declare type InsertCallback = CommitCallback;
InsertResponse
export declare type InsertResponse = CommitResponse;
LongRunningResponse
export declare type LongRunningResponse = [Operation, google.longrunning.IOperation];
PathType
export declare type PathType = string | number | entity.Int;
UpdateCallback
export declare type UpdateCallback = CommitCallback;
UpdateResponse
export declare type UpdateResponse = CommitResponse;
UpsertCallback
export declare type UpsertCallback = CommitCallback;
UpsertResponse
export declare type UpsertResponse = CommitResponse;