public interface DatastoreOperations
| Modifier and Type | Method and Description |
|---|---|
long |
count(Class<?> entityClass)
Count all occurrences of entities of the given domain type.
|
com.google.cloud.datastore.Key |
createKey(String kind,
Object id)
Create a
Key from kind name and id. |
<T> void |
delete(T entity)
Delete an entity from Cloud Datastore.
|
long |
deleteAll(Class<?> entityClass)
Delete all entities of a given domain type.
|
<T> void |
deleteAll(Iterable<T> entities)
Deletes multiple entities from Cloud Datastore.
|
<T> void |
deleteAllById(Iterable<?> ids,
Class<T> entityClass)
Delete multiple IDs from Cloud Datastore.
|
<T> void |
deleteById(Object id,
Class<T> entityClass)
Delete an entity from Cloud Datastore.
|
<T> boolean |
existsById(Object id,
Class<T> entityClass)
Check if the given ID belongs to an entity in Cloud Datastore.
|
<T> Iterable<T> |
findAll(Class<T> entityClass)
Get all the entities of the given domain type.
|
<T> Collection<T> |
findAll(Class<T> entityClass,
DatastoreQueryOptions queryOptions)
Get all the entities of the given domain type applying limit, offset and sort.
|
<T> Iterable<T> |
findAllById(Iterable<?> ids,
Class<T> entityClass)
Find all the entities of the given IDs.
|
<T> T |
findById(Object id,
Class<T> entityClass)
Get an entity based on a id.
|
<T> Map<String,T> |
findByIdAsMap(com.google.cloud.datastore.Key key,
Class<T> valueType)
Get a Datastore entity based on a id and convert it to a map.
|
<A> A |
performTransaction(Function<DatastoreOperations,A> operations)
Performs multiple read and write operations in a single transaction.
|
<T> Iterable<T> |
query(com.google.cloud.datastore.Query<? extends com.google.cloud.datastore.BaseEntity> query,
Class<T> entityClass)
Finds objects by using a Cloud Datastore query.
|
<A,T> Iterable<T> |
query(com.google.cloud.datastore.Query<A> query,
Function<A,T> entityFunc)
Runs given query and applies given function to each entity in the result.
|
Iterable<com.google.cloud.datastore.Key> |
queryKeys(com.google.cloud.datastore.Query<com.google.cloud.datastore.Key> query)
Finds Cloud Datastore Keys by using a Cloud Datastore query.
|
<T> T |
save(T instance,
com.google.cloud.datastore.Key... ancestors)
Saves an instance of an object to Cloud Datastore.
|
<T> Iterable<T> |
saveAll(Iterable<T> entities,
com.google.cloud.datastore.Key... ancestors)
Saves multiple instances of objects to Cloud Datastore.
|
<V> void |
writeMap(com.google.cloud.datastore.Key key,
Map<String,V> map)
Save a map as a Datastore entity, using map keys as field names.
|
<T> T findById(Object id, Class<T> entityClass)
T - the class type of the entity.id - the id of the entity. If this is actually a
Key then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass. param.entityClass - the type of the entity to get.<T> T save(T instance,
com.google.cloud.datastore.Key... ancestors)
T - the type of the object to saveinstance - the instance to save.ancestors - ancestors that should be added to the entry<T> Iterable<T> saveAll(Iterable<T> entities, com.google.cloud.datastore.Key... ancestors)
T - the type of entities to saveentities - the objects to save.ancestors - ancestors that should be added to each entry<T> void deleteById(Object id, Class<T> entityClass)
T - ths entity typeid - the ID of the entity to delete. If this is actually a
Key then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.entityClass - the type of the<T> void deleteAllById(Iterable<?> ids, Class<T> entityClass)
T - ths entity typeids - the IDs to delete. If any of these is actually a
Key then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.entityClass - the type of the<T> void delete(T entity)
T - the entity typeentity - the entity to delete.<T> void deleteAll(Iterable<T> entities)
T - the entity type.entities - the entities to delete.long deleteAll(Class<?> entityClass)
entityClass - the domain type to delete from Cloud Datastore.long count(Class<?> entityClass)
entityClass - the domain type to count.<T> Iterable<T> findAllById(Iterable<?> ids, Class<T> entityClass)
Key then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.T - the type parameter of the domain type.ids - the IDs to search.entityClass - the domain type of the objects.<T> Iterable<T> query(com.google.cloud.datastore.Query<? extends com.google.cloud.datastore.BaseEntity> query, Class<T> entityClass)
T - the type of object to retrieve.query - the query to execute.entityClass - the type of object to retrieve.<A,T> Iterable<T> query(com.google.cloud.datastore.Query<A> query, Function<A,T> entityFunc)
A - the row type of the query. This type can be either Key or a
Cloud Datastore entity.T - the type to map each entity or key to.query - the query to run.entityFunc - the function to apply to each found entity or key.Iterable<com.google.cloud.datastore.Key> queryKeys(com.google.cloud.datastore.Query<com.google.cloud.datastore.Key> query)
query - the query to execute that retrieves only Keys.<T> Iterable<T> findAll(Class<T> entityClass)
T - the type param of the domain type.entityClass - the domain type to get.<T> Collection<T> findAll(Class<T> entityClass, DatastoreQueryOptions queryOptions)
T - the type param of the domain type.entityClass - the domain type to get.queryOptions - query options<T> boolean existsById(Object id, Class<T> entityClass)
Key then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.T - the type param of the domain type.id - the ID to search for.entityClass - the domain type of the entities to search for.<A> A performTransaction(Function<DatastoreOperations,A> operations)
A - the final return type of the operations.operations - the function that uses DatastoreOperations
to perform operations in a transaction.<T> Map<String,T> findByIdAsMap(com.google.cloud.datastore.Key key, Class<T> valueType)
T - the value type of the mapkey - the key of the entityvalueType - type values should be converted tonull otherwise<V> void writeMap(com.google.cloud.datastore.Key key,
Map<String,V> map)
V - the value type of the map to writekey - the key for the entitymap - a mapCopyright © 2019 Pivotal Software, Inc.. All rights reserved.