All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.spring.data.cosmos.repository.CosmosRepository Maven / Gradle / Ivy

There is a newer version: 5.16.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.spring.data.cosmos.repository;

import com.azure.cosmos.models.PartitionKey;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.io.Serializable;
import java.util.Optional;

/**
 * Extension of {@link PagingAndSortingRepository} to provide additional methods to retrieve entities using the
 * pagination and sorting abstraction.
 */
@NoRepositoryBean
public interface CosmosRepository extends PagingAndSortingRepository {

    /**
     * Retrieves an entity by its id.
     *
     * @param id must not be {@literal null}.
     * @param partitionKey partition key value of entity, must not be null.
     * @return the entity with the given id or {@literal Optional#empty()} if none found
     * @throws IllegalArgumentException if {@code id} is {@literal null}.
     */
    Optional findById(ID id, PartitionKey partitionKey);

    /**
     * Deletes an entity by its id and partition key.
     *
     * @param id must not be {@literal null}.
     * @param partitionKey partition key value of the entity, must not be null.
     * @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
     */
    void deleteById(ID id, PartitionKey partitionKey);

    /**
     * Returns list of items in a specific partition
     *
     * @param partitionKey partition key value
     * @return Iterable of items with partition key value
     */
    Iterable findAll(PartitionKey partitionKey);

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy