Package com.google.cloud.datastore
A client for Cloud Datastore – A highly-scalable NoSQL database for web and mobile applications.
Here's a simple usage example for using google-cloud from App/Compute Engine. This example shows how to create a Datastore entity. For the complete source code see CreateEntity.java.
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind");
Key key = keyFactory.newKey("keyName");
Entity entity = Entity.newBuilder(key)
.set("name", "John Doe")
.set("age", 30)
.set("access_time", Timestamp.now())
.build();
datastore.put(entity);
This second example shows how to get and update a Datastore entity if it exists. For the complete source code see UpdateEntity.java.
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind");
Key key = keyFactory.newKey("keyName");
Entity entity = datastore.get(key);
if (entity != null) {
System.out.println("Updating access_time for " + entity.getString("name"));
entity = Entity.newBuilder(entity)
.set("access_time", Timestamp.now())
.build();
datastore.update(entity);
}
When using google-cloud from outside of App/Compute Engine, you have to specify a project ID and provide credentials.
- See Also:
- Google Cloud Datastore
-
Interface Summary Interface Description Batch An interface to represent a batch of write operations.Batch.Response Datastore An interface for Google Cloud Datastore.Datastore.TransactionCallable<T> A callback for running with a transactionalDatastoreReaderWriter
.DatastoreBatchWriter An interface to represent a batch of write operations.DatastoreFactory An interface for Datastore factories.DatastoreReader An interface to represent Google Cloud Datastore read operations.DatastoreReaderWriter An interface that combines both Google Cloud Datastore read and write operations.DatastoreWriter An interface to represent Google Cloud Datastore write operations.QueryResults<V> The result of a Google Cloud Datastore query submission.RecordQuery<V> An internal marker interface to representQuery
that returns the entity records.StructuredQuery.Builder<V> Interface for StructuredQuery builders.Transaction A Google cloud datastore transaction.Transaction.Response ValueBuilder<V,P extends Value<V>,B extends ValueBuilder<V,P,B>> A common interface for Value builders. -
Class Summary Class Description AggregationQuery An implementation of a Google Cloud Datastore Query that returnsAggregationResults
, It can be constructed by providing a nested query (StructuredQuery
orGqlQuery
) to run the aggregations on and a set ofAggregation
.AggregationQuery.Builder AggregationResult Represents a result of anAggregationQuery
query submission.AggregationResults The result of anAggregationQuery
query submission.BaseDatastoreBatchWriter Base class for DatastoreBatchWriter.BaseEntity<K extends IncompleteKey> A base class for entities (key and properties).BaseEntity.Builder<K extends IncompleteKey,B extends BaseEntity.Builder<K,B>> BaseKey Base class for keys.BaseKey.Builder<B extends BaseKey.Builder<B>> Base class for key builders.Blob A Google Cloud Datastore Blob.BlobValue BlobValue.Builder BooleanValue BooleanValue.Builder Cursor A Google Cloud Datastore cursor.DatastoreOptions DatastoreOptions.Builder DatastoreOptions.DefaultDatastoreFactory DatastoreOptions.DefaultDatastoreRpcFactory DoubleValue DoubleValue.Builder Entity An entity is the Google Cloud Datastore persistent data object for a specific key.Entity.Builder EntityQuery An implementation of a Google Cloud Datastore entity query that can be constructed by providing all the specific query elements.EntityQuery.Builder AEntityQuery
builder for queries that returnEntity
results.EntityValue EntityValue.Builder FullEntity<K extends IncompleteKey> A full entity is aBaseEntity
that holds all the properties associated with a Datastore entity (as opposed toProjectionEntity
).FullEntity.Builder<K extends IncompleteKey> GqlQuery<V> A Google Cloud Datastore GQL query.GqlQuery.Builder<V> A GQL query builder.GqlQueryProtoPreparer IncompleteKey An incomplete key (without a name or id).IncompleteKey.Builder Key A key that is guaranteed to be complete and could be used to reference a Google Cloud DatastoreEntity
.Key.Builder KeyFactory A helper for creating keys for a specificDatastore
, using its associated projectId and namespace.KeyQuery An implementation of a Google Cloud Datastore key-only query that can be constructed by providing all the specific query elements.KeyQuery.Builder AKeyQuery
builder for queries that returnKey
results.KeyValue KeyValue.Builder LatLng A Google Cloud Datastore LatLng (represented by latitude and longitude in degrees).LatLngValue LatLngValue.Builder ListValue A Google Cloud Datastore list value.ListValue.Builder LongValue LongValue.Builder NullValue NullValue.Builder PathElement Represents a single element in a key's path.ProjectionEntity A projection entity is a result of a Google Cloud Datastore projection query.ProjectionEntity.Builder ProjectionEntityQuery An implementation of a Google Cloud Datastore projection entity query that can be constructed by providing all the specific query elements.ProjectionEntityQuery.Builder AProjectionEntityQuery
builder for queries that returnProjectionEntity
results.Query<V> A Google Cloud Datastore query.Query.ResultType<V> This class represents the expected type of the result.RawValue RawValue.Builder ReadOption Specifies options for read operations in Datastore, namely getting/fetching entities and running queries.ReadOption.EventualConsistency Specifies eventual consistency for reads from Datastore.ReadOption.QueryAndReadOptions<Q extends Query<?>> ReadOption.ReadTime Reads entities as they were at the given time.ReadOptionProtoPreparer RetryAndTraceDatastoreRpcDecorator An implementation ofDatastoreRpc
which acts as a Decorator and decorates the underlyingDatastoreRpc
with the logic of retry and Traceability.StringValue StringValue.Builder StructuredQuery<V> An implementation of a Google Cloud Datastore Query that can be constructed by providing all the specific query elements.StructuredQuery.CompositeFilter A class representing a filter composed of a combination of other filters.StructuredQuery.Filter StructuredQuery.OrderBy StructuredQuery.OrderBy.Direction StructuredQuery.PropertyFilter A class representing a filter based on a single property or ancestor.StructuredQueryProtoPreparer TimestampValue TimestampValue.Builder TraceUtil Helper class for tracing utility.TransactionExceptionHandler TransactionOperationExceptionHandler Value<V> Base class for all Google Cloud Datastore value types. -
Enum Summary Enum Description AggregationQuery.Mode ValueType The type of a Datastore property. -
Exception Summary Exception Description DatastoreException Datastore service exception.