CosmosRepository<T,ID> Interface

Type Parameters

T

domain type.

ID

id type.

Implements

org.springframework.data.repository.CrudRepository<T,ID> org.springframework.data.repository.PagingAndSortingRepository<T,ID>

public interface CosmosRepository<T,ID>
extends org.springframework.data.repository.PagingAndSortingRepository<T,ID>, org.springframework.data.repository.CrudRepository<T,ID>

Extension of PagingAndSortingRepository to provide additional methods to retrieve entities using the pagination and sorting abstraction.

Method Summary

Modifier and Type Method and Description
abstract void deleteById(ID id, PartitionKey partitionKey)

Deletes an entity by its id and partition key.

abstract Iterable<T> findAll(PartitionKey partitionKey)

Returns list of items in a specific partition

abstract Optional<T> findById(ID id, PartitionKey partitionKey)

Retrieves an entity by its id.

abstract S save(ID id, PartitionKey partitionKey, Class<S> domainType, CosmosPatchOperations patchOperations)

Patches an entity by its id and partition key with CosmosPatchItemRequestOptions

abstract S save(ID id, PartitionKey partitionKey, Class<S> domainType, CosmosPatchOperations patchOperations, CosmosPatchItemRequestOptions options)

Patches an entity by its id and partition key with CosmosPatchItemRequestOptions

Method Details

deleteById

public abstract void deleteById(ID id, PartitionKey partitionKey)

Deletes an entity by its id and partition key.

Parameters:

id - must not be null.
partitionKey - partition key value of the entity, must not be null.

findAll

public abstract Iterable findAll(PartitionKey partitionKey)

Returns list of items in a specific partition

Parameters:

partitionKey - partition key value

Returns:

Iterable of items with partition key value

findById

public abstract Optional findById(ID id, PartitionKey partitionKey)

Retrieves an entity by its id.

Parameters:

id - must not be null.
partitionKey - partition key value of entity, must not be null.

Returns:

the entity with the given id or Optional#empty() if none found

save

public abstract S save(ID id, PartitionKey partitionKey, Class domainType, CosmosPatchOperations patchOperations)

Patches an entity by its id and partition key with CosmosPatchItemRequestOptions

Parameters:

id - must not be null
partitionKey - must not be null
domainType - must not be null
patchOperations - must not be null, max operations is 10

Returns:

the patched entity

save

public abstract S save(ID id, PartitionKey partitionKey, Class domainType, CosmosPatchOperations patchOperations, CosmosPatchItemRequestOptions options)

Patches an entity by its id and partition key with CosmosPatchItemRequestOptions

Parameters:

id - must not be null
partitionKey - must not be null
domainType - must not be null
patchOperations - must not be null, max operations is 10
options - Optional CosmosPatchItemRequestOptions, e.g. options.setFilterPredicate("FROM products p WHERE p.used = false");

Returns:

the patched entity

Applies to