Package com.google.cloud.datastore
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:
-
ClassDescriptionAn implementation of a Google Cloud Datastore Query that returns
AggregationResults
, It can be constructed by providing a nested query (StructuredQuery
orGqlQuery
) to run the aggregations on and a set ofAggregation
.Represents a result of anAggregationQuery
query submission.The result of anAggregationQuery
query submission.Base class for DatastoreBatchWriter.BaseEntity<K extends IncompleteKey>A base class for entities (key and properties).Base class for keys.BaseKey.Builder<B extends BaseKey.Builder<B>>Base class for key builders.An interface to represent a batch of write operations.A Google Cloud Datastore Blob.A Google Cloud Datastore cursor.An interface for Google Cloud Datastore.A callback for running with a transactionalDatastoreReaderWriter
.An interface to represent a batch of write operations.Datastore service exception.An interface for Datastore factories.An interface to represent Google Cloud Datastore read operations.An interface that combines both Google Cloud Datastore read and write operations.An interface to represent Google Cloud Datastore write operations.An entity is the Google Cloud Datastore persistent data object for a specific key.An implementation of a Google Cloud Datastore entity query that can be constructed by providing all the specific query elements.AEntityQuery
builder for queries that returnEntity
results.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.A GQL query builder.An incomplete key (without a name or id).A key that is guaranteed to be complete and could be used to reference a Google Cloud DatastoreEntity
.A helper for creating keys for a specificDatastore
, using its associated projectId and namespace.An implementation of a Google Cloud Datastore key-only query that can be constructed by providing all the specific query elements.AKeyQuery
builder for queries that returnKey
results.A Google Cloud Datastore LatLng (represented by latitude and longitude in degrees).A Google Cloud Datastore list value.Represents a single element in a key's path.A projection entity is a result of a Google Cloud Datastore projection query.An implementation of a Google Cloud Datastore projection entity query that can be constructed by providing all the specific query elements.AProjectionEntityQuery
builder for queries that returnProjectionEntity
results.Query<V>A Google Cloud Datastore query.This class represents the expected type of the result.QueryResults<V>The result of a Google Cloud Datastore query submission.Specifies options for read operations in Datastore, namely getting/fetching entities and running queries.Specifies eventual consistency for reads from Datastore.ReadOption.QueryConfig<Q extends Query<?>>Reads entities as they were at the given time.RecordQuery<V>An internal marker interface to representQuery
that returns the entity records.An implementation ofDatastoreRpc
which acts as a Decorator and decorates the underlyingDatastoreRpc
with the logic of retry and Traceability.An implementation of a Google Cloud Datastore Query that can be constructed by providing all the specific query elements.Interface for StructuredQuery builders.A class representing a filter composed of a combination of other filters.A class representing a filter based on a single property or ancestor.A Google cloud datastore transaction.Value<V>Base class for all Google Cloud Datastore value types.ValueBuilder<V,P extends Value<V>, B extends ValueBuilder<V, P, B>> A common interface for Value builders.The type of a Datastore property.