Interface CosmosOperations
- All Known Implementing Classes:
CosmosTemplate
public interface CosmosOperations
Interface for cosmosDB operations
-
Method Summary
Modifier and TypeMethodDescription<T> longcount(SqlQuerySpec querySpec, String containerName) Count<T> longcount(CosmosQuery query, String containerName) CountlongCountcreateContainerIfNotExists(CosmosEntityInformation<?, ?> information) Creates container if not exists<T> Iterable<T>delete(CosmosQuery query, Class<T> domainType, String containerName) Delete items matching queryvoidDelete 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>Find the DocumentQuery, find all the items specified by domain type.<T> Iterable<T>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> TFinds item by id<T> TfindById(Object id, Class<T> domainType, PartitionKey partitionKey) Finds item by id<T> TFinds item by id<T,ID> Iterable<T> Find by idsgetContainerName(Class<?> domainType) To get container name by domainTypegetContainerProperties(String containerName) Get properties for specified containerTo get converter<T> TInserts 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 queryreplaceContainerProperties(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> voidUpserts 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 Details
-
getContainerName
To get container name by domainType- Parameters:
domainType- class type- Returns:
- String
-
createContainerIfNotExists
Creates container if not exists- Parameters:
information- CosmosEntityInformation- Returns:
- CosmosContainerProperties
-
getContainerProperties
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
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
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
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
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
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
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
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
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
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
Upserts an item into container with partition key- Type Parameters:
T- type of upsert object- Parameters:
containerName- the container nameobject- upsert object
-
upsertAndReturnEntity
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
Delete an item by id- Parameters:
containerName- the container nameid- the idpartitionKey- the partition key
-
deleteEntity
Delete using entity- Type Parameters:
T- type class of domain type- Parameters:
containerName- the container nameentity- the entity object
-
deleteAll
Delete all items in a container- Parameters:
containerName- the container namedomainType- the domainType
-
deleteContainer
Delete container- Parameters:
containerName- the container name
-
delete
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
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
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
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
Count- Parameters:
containerName- the container name- Returns:
- count result
-
count
Count- Type Parameters:
T- type class of domainType- Parameters:
query- the document querycontainerName- the container name- Returns:
- count result
-
count
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
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
-