你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

SimpleCosmosRepository<T,ID> Class

  • java.lang.Object
    • com.azure.spring.data.cosmos.repository.support.SimpleCosmosRepository<T,ID>

Type Parameters

T

domain type.

ID

id type.

Implements

public class SimpleCosmosRepository<T,ID>
implements CosmosRepository<T,ID>

Repository class for simple Cosmos operation

Constructor Summary

Constructor Description
SimpleCosmosRepository(CosmosEntityInformation<T,ID> metadata, CosmosOperations dbOperations)

Initialization

Method Summary

Modifier and Type Method and Description
S save(ID id, PartitionKey partitionKey, Class<S> domainType, CosmosPatchOperations patchOperations)

patch entity with CosmosPatchItemRequestOptions

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

patch entity with CosmosPatchItemRequestOptions

S save(S entity)

save entity without partition

Iterable<S> saveAll(Iterable<S> entities)

Batch save entities.

long count()

return count of documents in one container without partitions

void delete(T entity)

delete one document per entity

void deleteAll()

Delete all the domains of a container.

void deleteAll(Iterable<? extends T> entities)

Delete list of entities without partitions.

void deleteAllById(Iterable<? extends ID> ids)
void deleteById(ID id)

delete one document per id without configuring partition key value

void deleteById(ID id, PartitionKey partitionKey)

Deletes an entity by its id and partition key.

boolean existsById(ID primaryKey)

check if an entity exists per id without partition

Iterable<T> findAll()

find all entities from one container without configuring partition key value

Iterable<T> findAll(PartitionKey partitionKey)

Returns list of items in a specific partition

org.springframework.data.domain.Page<T> findAll(Pageable pageable)

FindQuerySpecGenerator Returns a Page of entities meeting the paging restriction provided in the Pageable object.

Iterable<T> findAll(Sort sort)

Returns all entities sorted by the given options.

Iterable<T> findAllById(Iterable<ID> ids)

find entities based on id list from one container without partitions

Optional<T> findById(ID id)

find one entity per id without partitions

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

Retrieves an entity by its id.

Methods inherited from java.lang.Object

Constructor Details

SimpleCosmosRepository

public SimpleCosmosRepository(CosmosEntityInformation metadata, CosmosOperations dbOperations)

Initialization

Parameters:

metadata - for cosmos entity information
dbOperations - for cosmosDB operation

Method Details

save

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

patch entity with CosmosPatchItemRequestOptions

Parameters:

id - of entity to be patched
partitionKey - of entity to be patched
domainType
patchOperations - for entity to be patched

save

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

patch entity with CosmosPatchItemRequestOptions

Parameters:

id - of entity to be patched
partitionKey - of entity to be patched
domainType
patchOperations - for entity to be patched
options - options

save

public S save(S entity)

save entity without partition

Parameters:

entity - to be saved

Returns:

entity

saveAll

public Iterable saveAll(Iterable entities)

Batch save entities. Uses bulk if possible.

Parameters:

entities - Batch entities

Returns:

return the saved entities

count

public long count()

return count of documents in one container without partitions

Returns:

count of documents in one container without partitions

delete

public void delete(T entity)

delete one document per entity

Parameters:

entity - the entity used to specify a document

deleteAll

public void deleteAll()

Delete all the domains of a container. Uses bulk if possible.

deleteAll

public void deleteAll(Iterable entities)

Delete list of entities without partitions. Uses bulk if possible.

Parameters:

entities - list of entities to be deleted

deleteAllById

public void deleteAllById(Iterable ids)

Parameters:

ids

deleteById

public void deleteById(ID id)

delete one document per id without configuring partition key value

Parameters:

id - an id used to specify the deleted document

deleteById

public void deleteById(ID id, PartitionKey partitionKey)

Deletes an entity by its id and partition key.

Parameters:

id
partitionKey

existsById

public boolean existsById(ID primaryKey)

check if an entity exists per id without partition

Parameters:

primaryKey - an id to specify an entity

Returns:

if the entity exists

findAll

public Iterable findAll()

find all entities from one container without configuring partition key value

Returns:

return Iterable of the found entities List

findAll

public Iterable findAll(PartitionKey partitionKey)

Returns list of items in a specific partition

Parameters:

partitionKey

findAll

public Page findAll(Pageable pageable)

FindQuerySpecGenerator Returns a Page of entities meeting the paging restriction provided in the Pageable object.

Parameters:

pageable - the Pageable object providing paging restriction

Returns:

a page of entities

findAll

public Iterable findAll(Sort sort)

Returns all entities sorted by the given options.

Parameters:

sort - the Sort option for queries.

Returns:

all entities sorted by the given options

findAllById

public Iterable findAllById(Iterable ids)

find entities based on id list from one container without partitions

Parameters:

ids - id list used to find entities

Returns:

return a List of all found entities

findById

public Optional findById(ID id)

find one entity per id without partitions

Parameters:

id - an id used to find entity

Returns:

return the searching result

findById

public Optional findById(ID id, PartitionKey partitionKey)

Retrieves an entity by its id.

Parameters:

id
partitionKey

Applies to