Interface CosmosOperations
-
- All Known Implementing Classes:
CosmosTemplate
public interface CosmosOperationsInterface for cosmosDB operations
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> longcount(SqlQuerySpec querySpec, String containerName)Count<T> longcount(CosmosQuery query, String containerName)Countlongcount(String containerName)CountCosmosContainerPropertiescreateContainerIfNotExists(CosmosEntityInformation<?,?> information)Creates container if not exists<T> Iterable<T>delete(CosmosQuery query, Class<T> domainType, String containerName)Delete items matching queryvoiddeleteAll(String containerName, Class<?> domainType)Delete all items in a containervoiddeleteById(String containerName, Object id, PartitionKey partitionKey)Delete an item by idvoiddeleteContainer(String containerName)Delete container<T> voiddeleteEntity(String containerName, T entity)Delete using entity<T> Booleanexists(CosmosQuery query, Class<T> domainType, String containerName)Exists<T> Iterable<T>find(CosmosQuery query, Class<T> domainType, String containerName)Find query<T> Iterable<T>findAll(PartitionKey partitionKey, Class<T> domainType)Find the DocumentQuery, find all the items specified by domain type in the given container.<T> Iterable<T>findAll(Class<T> domainType)Find the DocumentQuery, find all the items specified by domain type.<T> Iterable<T>findAll(String containerName, Class<T> domainType)Find the DocumentQuery, find all the items specified by domain type in the given container.<T> org.springframework.data.domain.Page<T>findAll(org.springframework.data.domain.Pageable pageable, Class<T> domainType, String containerName)Find all items in a given container with partition key<T> TfindById(Object id, Class<T> domainType)Finds item by id<T> TfindById(Object id, Class<T> domainType, PartitionKey partitionKey)Finds item by id<T> TfindById(String containerName, Object id, Class<T> domainType)Finds item by id<T,ID>
Iterable<T>findByIds(Iterable<ID> ids, Class<T> domainType, String containerName)Find by idsStringgetContainerName(Class<?> domainType)To get container name by domainTypeCosmosContainerPropertiesgetContainerProperties(String containerName)Get properties for specified containerMappingCosmosConvertergetConverter()To get converter<T> Tinsert(String containerName, T objectToSave)Inserts item<T> Tinsert(String containerName, T objectToSave, PartitionKey partitionKey)Inserts item<T> Tinsert(T objectToSave, PartitionKey partitionKey)Inserts item<T> org.springframework.data.domain.Page<T>paginationQuery(CosmosQuery query, Class<T> domainType, String containerName)Pagination queryCosmosContainerPropertiesreplaceContainerProperties(String containerName, CosmosContainerProperties properties)Replace container properties for the specified container<T> org.springframework.data.domain.Page<T>runPaginationQuery(SqlQuerySpec querySpec, org.springframework.data.domain.Pageable pageable, Class<?> domainType, Class<T> returnType)Run the query.<T> Iterable<T>runQuery(SqlQuerySpec querySpec, Class<?> domainType, Class<T> returnType)Run the query.<T> Iterable<T>runQuery(SqlQuerySpec querySpec, org.springframework.data.domain.Sort sort, Class<?> domainType, Class<T> returnType)Run the query.<T> org.springframework.data.domain.Slice<T>runSliceQuery(SqlQuerySpec querySpec, org.springframework.data.domain.Pageable pageable, Class<?> domainType, Class<T> returnType)Run custom SQL query<T> org.springframework.data.domain.Slice<T>sliceQuery(CosmosQuery query, Class<T> domainType, String containerName)Slice query<T> voidupsert(String containerName, T object)Upserts an item into container with partition key<T> voidupsert(T object)Upserts an item with partition key<T> TupsertAndReturnEntity(String containerName, T object)Upserts an item and return item properties
-
-
-
Method Detail
-
getContainerName
String getContainerName(Class<?> domainType)
To get container name by domainType- Parameters:
domainType- class type- Returns:
- String
-
createContainerIfNotExists
CosmosContainerProperties createContainerIfNotExists(CosmosEntityInformation<?,?> information)
Creates container if not exists- Parameters:
information- CosmosEntityInformation- Returns:
- CosmosContainerProperties
-
getContainerProperties
CosmosContainerProperties getContainerProperties(String containerName)
Get properties for specified container- Parameters:
containerName- String- Returns:
- CosmosContainerProperties
-
replaceContainerProperties
CosmosContainerProperties replaceContainerProperties(String containerName, CosmosContainerProperties properties)
Replace container properties for the specified container- Parameters:
containerName- Stringproperties- CosmosContainerProperties- Returns:
- CosmosContainerProperties
-
findAll
<T> Iterable<T> findAll(Class<T> domainType)
Find the DocumentQuery, find all the items specified by domain type.- Type Parameters:
T- class type of domain- Parameters:
domainType- the domain type- Returns:
- results in an Iterable
-
findAll
<T> Iterable<T> findAll(String containerName, Class<T> domainType)
Find the DocumentQuery, find all the items specified by domain type in the given container.- Type Parameters:
T- class type of domain- Parameters:
containerName- the container namedomainType- the domain type- Returns:
- results in an Iterable
-
findAll
<T> Iterable<T> findAll(PartitionKey partitionKey, Class<T> domainType)
Find the DocumentQuery, find all the items specified by domain type in the given container.- Type Parameters:
T- class type of domain- Parameters:
partitionKey- the partition keydomainType- the domain type- Returns:
- results in an Iterable
-
findById
<T> T findById(Object id, Class<T> domainType)
Finds item by id- Type Parameters:
T- type class of domain type- Parameters:
id- must not be nulldomainType- must not be null- Returns:
- found item
-
findById
<T> T findById(String containerName, Object id, Class<T> domainType)
Finds item by id- Type Parameters:
T- type class of domain type- Parameters:
containerName- must not be nullid- must not be nulldomainType- must not be null- Returns:
- found item
-
findById
<T> T findById(Object id, Class<T> domainType, PartitionKey partitionKey)
Finds item by id- Type Parameters:
T- type class of domain type- Parameters:
id- must not be nulldomainType- must not be nullpartitionKey- must not be null- Returns:
- found item
-
insert
<T> T insert(T objectToSave, PartitionKey partitionKey)Inserts item- Type Parameters:
T- type class of domain type- Parameters:
objectToSave- must not be nullpartitionKey- must not be null- Returns:
- the inserted item
-
insert
<T> T insert(String containerName, T objectToSave, PartitionKey partitionKey)
Inserts item- Type Parameters:
T- type class of domain type- Parameters:
containerName- must not be nullobjectToSave- must not be nullpartitionKey- must not be null- Returns:
- the inserted item
-
insert
<T> T insert(String containerName, T objectToSave)
Inserts item- Type Parameters:
T- type class of domain type- Parameters:
containerName- must not be nullobjectToSave- must not be null- Returns:
- the inserted item
-
upsert
<T> void upsert(T object)
Upserts an item with partition key- Type Parameters:
T- type of upsert object- Parameters:
object- upsert object
-
upsert
<T> void upsert(String containerName, T object)
Upserts an item into container with partition key- Type Parameters:
T- type of upsert object- Parameters:
containerName- the container nameobject- upsert object
-
upsertAndReturnEntity
<T> T upsertAndReturnEntity(String containerName, T object)
Upserts an item and return item properties- Type Parameters:
T- type of upsert object- Parameters:
containerName- the container nameobject- upsert object- Returns:
- upsert object entity
-
deleteById
void deleteById(String containerName, Object id, PartitionKey partitionKey)
Delete an item by id- Parameters:
containerName- the container nameid- the idpartitionKey- the partition key
-
deleteEntity
<T> void deleteEntity(String containerName, T entity)
Delete using entity- Type Parameters:
T- type class of domain type- Parameters:
containerName- the container nameentity- the entity object
-
deleteAll
void deleteAll(String containerName, Class<?> domainType)
Delete all items in a container- Parameters:
containerName- the container namedomainType- the domainType
-
deleteContainer
void deleteContainer(String containerName)
Delete container- Parameters:
containerName- the container name
-
delete
<T> Iterable<T> delete(CosmosQuery query, Class<T> domainType, String containerName)
Delete items matching query- Type Parameters:
T- type class of domainType- Parameters:
query- the document querydomainType- type classcontainerName- the container name- Returns:
- deleted items in a Iterable
-
find
<T> Iterable<T> find(CosmosQuery query, Class<T> domainType, String containerName)
Find query- Type Parameters:
T- type class of domainType- Parameters:
query- the document querydomainType- type classcontainerName- the container name- Returns:
- results in an Iterable
-
findByIds
<T,ID> Iterable<T> findByIds(Iterable<ID> ids, Class<T> domainType, String containerName)
Find by ids- Type Parameters:
T- type of domainTypeID- type of ID- Parameters:
ids- iterable of idsdomainType- type classcontainerName- the container name- Returns:
- results in an Iterable
-
exists
<T> Boolean exists(CosmosQuery query, Class<T> domainType, String containerName)
Exists- Type Parameters:
T- type of domainType- Parameters:
query- the document querydomainType- type classcontainerName- the container name- Returns:
- Boolean
-
findAll
<T> org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable, Class<T> domainType, String containerName)Find all items in a given container with partition key- Type Parameters:
T- type of domainType- Parameters:
pageable- Pageable objectdomainType- the domainTypecontainerName- the container name- Returns:
- results as Page
-
paginationQuery
<T> org.springframework.data.domain.Page<T> paginationQuery(CosmosQuery query, Class<T> domainType, String containerName)
Pagination query- Type Parameters:
T- type class of domainType- Parameters:
query- the document querydomainType- type classcontainerName- the container name- Returns:
- results as Page
-
sliceQuery
<T> org.springframework.data.domain.Slice<T> sliceQuery(CosmosQuery query, Class<T> domainType, String containerName)
Slice query- Type Parameters:
T- type class of domainType- Parameters:
query- the document querydomainType- type classcontainerName- the container name- Returns:
- results as Slice
-
runSliceQuery
<T> org.springframework.data.domain.Slice<T> runSliceQuery(SqlQuerySpec querySpec, org.springframework.data.domain.Pageable pageable, Class<?> domainType, Class<T> returnType)
Run custom SQL query- Type Parameters:
T- the type parameter- Parameters:
querySpec- the query specpageable- the pageabledomainType- the domain typereturnType- the return type- Returns:
- the Page
-
count
long count(String containerName)
Count- Parameters:
containerName- the container name- Returns:
- count result
-
count
<T> long count(CosmosQuery query, String containerName)
Count- Type Parameters:
T- type class of domainType- Parameters:
query- the document querycontainerName- the container name- Returns:
- count result
-
count
<T> long count(SqlQuerySpec querySpec, String containerName)
Count- Type Parameters:
T- type class of domainType- Parameters:
querySpec- the document query speccontainerName- the container name- Returns:
- count result
-
getConverter
MappingCosmosConverter getConverter()
To get converter- Returns:
- MappingCosmosConverter
-
runQuery
<T> Iterable<T> runQuery(SqlQuerySpec querySpec, Class<?> domainType, Class<T> returnType)
Run the query.- Type Parameters:
T- the type parameter- Parameters:
querySpec- the query specdomainType- the domain typereturnType- the return type- Returns:
- the Iterable
-
runQuery
<T> Iterable<T> runQuery(SqlQuerySpec querySpec, org.springframework.data.domain.Sort sort, Class<?> domainType, Class<T> returnType)
Run the query.- Type Parameters:
T- the type parameter- Parameters:
querySpec- the query specsort- the sort orderdomainType- the domain typereturnType- the return type- Returns:
- the Iterable
-
runPaginationQuery
<T> org.springframework.data.domain.Page<T> runPaginationQuery(SqlQuerySpec querySpec, org.springframework.data.domain.Pageable pageable, Class<?> domainType, Class<T> returnType)
Run the query.- Type Parameters:
T- the type parameter- Parameters:
querySpec- the query specpageable- the pageabledomainType- the domain typereturnType- the return type- Returns:
- the Page
-
-