Interface DynamoDbRepository<ENTITY_TYPE>


  • public interface DynamoDbRepository<ENTITY_TYPE>
    • Method Detail

      • dynamoDbClient

        default software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDbClient()
      • getRangeKeyName

        default String getRangeKeyName()
        Returns:
        Range Key name
      • getParameterType

        default Class<ENTITY_TYPE> getParameterType()
        Returns:
        Entity class
      • getHashKeyName

        default String getHashKeyName()
        Returns:
        hash key name of the entity
      • getFieldMappings

        default Map<String,​?> getFieldMappings​(ENTITY_TYPE item,
                                                     boolean includeNullValues)
        Returns map representation without primary keys
        Parameters:
        item - entity
        includeNullValues - Include null values. If true is sent, all values are returned else null values are eliminated
        Returns:
        Map
      • findByHashKey

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKey​(Object hashKeyValue)
        Returns a list of values matching hash key value passed.
        Parameters:
        hashKeyValue - Hash Key value
        Returns:
        List of entity objects
      • findByHashKey

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKey​(String hashKeyName,
                                                                       Object hashKeyValue)
        Returns a list of values matching hash key value passed.
        Parameters:
        hashKeyName - Hash Key Name
        hashKeyValue - Hash Key value
        Returns:
        List of entity objects
      • findByHashKey

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKey​(String hashKeyName,
                                                                       Object hashKeyValue,
                                                                       @Nullable
                                                                       Page page)
        Returns a flux (list) of values matching hash key value passed.
        Parameters:
        hashKeyName - Hash Key Name
        hashKeyValue - Hash Key value
        Returns:
        List of entity objects
      • findByHashKey

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKey​(String hashKeyName,
                                                                       Object hashKeyValueObj,
                                                                       @Nullable
                                                                       Expr expr)
      • findByHashKey

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKey​(String hashKeyName,
                                                                       Object hashKeyValueObj,
                                                                       @Nullable
                                                                       String indexName,
                                                                       @Nullable
                                                                       Expr expr)
        Returns a flux representing a list of values which matches the hash key value passed
        Parameters:
        hashKeyName - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        indexName - The GSI index name. This is used if the optional parameter has a value
        Returns:
        A Flux representing the list of values satisfying the above conditions.
      • findByHashKey

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKey​(String hashKeyName,
                                                                       Object hashKeyValueObj,
                                                                       @Nullable
                                                                       Page page,
                                                                       @Nullable
                                                                       String indexName,
                                                                       @Nullable
                                                                       Expr expr)
        Returns a flux representing a list of values which matches the hash key value passed
        Parameters:
        hashKeyName - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        indexName - The GSI index name. This is used if the optional parameter has a value
        Returns:
        A Flux representing the list of values satisfying the above conditions.
      • findByHashKeyAndRangeKeyStartsWith

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKeyAndRangeKeyStartsWith​(String hashKey,
                                                                                            Object hashKeyValueObj,
                                                                                            String rangeKey,
                                                                                            String rangeKeyValue)
        Returns a list of entities whose has hash key matches the value sent and the range key starts with the value sent.
        Parameters:
        hashKey - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        rangeKey - Range key.
        rangeKeyValue - Range Key Value
        Returns:
        List of entities
      • findByHashKeyAndRangeKeyStartsWith

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKeyAndRangeKeyStartsWith​(String hashKey,
                                                                                            Object hashKeyValueObj,
                                                                                            String rangeKey,
                                                                                            String rangeKeyValue,
                                                                                            @Nullable
                                                                                            Page page)
        Returns a list of entities whose has hash key matches the value sent and the range key starts with the value sent.
        Parameters:
        hashKey - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        rangeKey - Range key.
        rangeKeyValue - Range Key Value
        Returns:
        List of entities
      • findByHashKeyAndRangeKeyStartsWith

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKeyAndRangeKeyStartsWith​(String hashKey,
                                                                                            Object hashKeyValueObj,
                                                                                            String rangeKey,
                                                                                            String rangeKeyValue,
                                                                                            @Nullable
                                                                                            String indexName,
                                                                                            @Nullable
                                                                                            Expr expr)
        Parameters:
        hashKey - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        rangeKey - Range key.
        rangeKeyValue - Range Key Value
        indexName - Index name
        expr - filter expression
        Returns:
        list of entities
      • findByHashKeyAndRangeKeyStartsWith

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKeyAndRangeKeyStartsWith​(String hashKey,
                                                                                            Object hashKeyValueObj,
                                                                                            String rangeKey,
                                                                                            String rangeKeyValue,
                                                                                            @Nullable
                                                                                            Page page,
                                                                                            @Nullable
                                                                                            String indexName,
                                                                                            @Nullable
                                                                                            Expr expr)
        Parameters:
        hashKey - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        rangeKey - Range key.
        rangeKeyValue - Range Key Value
        indexName - Index name
        expr - filter expression
        Returns:
        list of entities
      • findByHashKeyAndRangeKeyStartsWithPagination

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKeyAndRangeKeyStartsWithPagination​(String hashKey,
                                                                                                      Object hashKeyValueObj,
                                                                                                      String rangeKey,
                                                                                                      String rangeKeyValue,
                                                                                                      @Nullable
                                                                                                      Page page)
        Parameters:
        hashKey - Hash Key used for the table
        hashKeyValueObj - The value of the Hash key
        rangeKey - Range key.
        rangeKeyValue - Range Key Value
        page - page details
        Returns:
        records matching the keys and page object
      • findByHashKeyAndRangeKeyStartsWithPagination

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByHashKeyAndRangeKeyStartsWithPagination​(String hashKey,
                                                                                                      Object hashKeyValueObj,
                                                                                                      String rangeKey,
                                                                                                      String rangeKeyValue,
                                                                                                      @Nullable
                                                                                                      Page page,
                                                                                                      @Nullable
                                                                                                      String indexName,
                                                                                                      @Nullable
                                                                                                      Expr expr)
        Parameters:
        hashKey - Hash Key Name
        hashKeyValueObj - Hash Key Value
        rangeKey - Range Key Name
        rangeKeyValue - Range Key Value
        page - Page
        indexName - Index name
        expr - Filter Expression
        Returns:
        Records matching above criteria
      • findBySecondaryIndex

        default reactor.core.publisher.Flux<ENTITY_TYPE> findBySecondaryIndex​(String indexName,
                                                                              Object hashKeyValueObj)
        Queries by GSI name and the hash key value used for the index
        Parameters:
        indexName - Name of the GSI
        hashKeyValueObj - hash key value
        Returns:
        list of items satisfying the above criteria
      • findBySecondaryIndex

        default reactor.core.publisher.Flux<ENTITY_TYPE> findBySecondaryIndex​(@NonNull
                                                                              String indexName,
                                                                              Object hashKeyValueObj,
                                                                              Object rangeKeyValue)
        Parameters:
        indexName - Queries by GSI name and the hash key value and range key used for the index
        hashKeyValueObj - hash key value
        rangeKeyValue - range key value
        Returns:
        list of items satisfying the above criteria
      • findBySecondaryIndex

        default reactor.core.publisher.Flux<ENTITY_TYPE> findBySecondaryIndex​(@NonNull
                                                                              String indexName,
                                                                              Object hashKeyValueObj,
                                                                              @Nullable
                                                                              Expr expr)
        Parameters:
        indexName - name of the GSI
        hashKeyValueObj - Hash Key Value
        expr - Filter Expression
        Returns:
        Multiple records
      • findBySecondaryIndex

        default reactor.core.publisher.Flux<ENTITY_TYPE> findBySecondaryIndex​(@NonNull
                                                                              String indexName,
                                                                              Object hashKeyValueObj,
                                                                              Object rangeKeyValue,
                                                                              @Nullable
                                                                              Expr expr)
        Parameters:
        indexName - name of the GSI
        hashKeyValueObj - Hash Key Value
        rangeKeyValue - Range Key Value
        expr - Filter Expression
        Returns:
        Multiple records
      • findOne

        default reactor.core.publisher.Mono<ENTITY_TYPE> findOne​(PrimaryKey primaryKey)
        Returns a single record by primary key (Hash Key + Sort Key[if there is one])
        Parameters:
        primaryKey - Primary Key Object
        Returns:
        A single record
      • findAll

        default reactor.core.publisher.Flux<ENTITY_TYPE> findAll()
        Get all records. Limit set to 20
        Returns:
        list of all records
      • findAll

        default reactor.core.publisher.Flux<ENTITY_TYPE> findAll​(int limit)
        Get all records
        Parameters:
        limit - Page Size
        Returns:
        List of all records
      • findAll

        default reactor.core.publisher.Flux<ENTITY_TYPE> findAll​(@Nullable
                                                                 Expr expr)
        Parameters:
        expr - Filter Expression
        Returns:
        All records that satisfy the filter criteria
      • findAll

        default reactor.core.publisher.Flux<ENTITY_TYPE> findAll​(@Nullable
                                                                 Expr expr,
                                                                 int limit)
        Parameters:
        expr -
        expr - Filter Expression
        limit - limit
        Returns:
        All records that satisfy the filter criteria
      • findByPrimaryKey

        default reactor.core.publisher.Mono<ENTITY_TYPE> findByPrimaryKey​(@NonNull
                                                                          PrimaryKey primaryKey)
        Returns a record which matches the primary key passed
        Parameters:
        primaryKey - Primary Key (this should have both the hash key and the sort key populated)
        Returns:
        A mono representing a record which matches the primary key passed.
      • findByPrimaryKey

        default reactor.core.publisher.Mono<ENTITY_TYPE> findByPrimaryKey​(Object hashKeyValue)
      • findByPrimaryKey

        default reactor.core.publisher.Mono<ENTITY_TYPE> findByPrimaryKey​(Object hashKeyValue,
                                                                          Object rangeKeyValue)
      • findBy

        default reactor.core.publisher.Flux<ENTITY_TYPE> findBy​(PrimaryKey... primaryKeys)
        Parameters:
        primaryKeys - List of Primary keys
        Returns:
        multiple records
      • findByPrimaryKeys

        default reactor.core.publisher.Flux<ENTITY_TYPE> findByPrimaryKeys​(@NonNull
                                                                           List<PrimaryKey> primaryKeys)
        Parameters:
        primaryKeys - List of primary keys
        Returns:
        Records matching above criteria
      • putItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> putItem​(@NonNull
                                                                 ENTITY_TYPE item)
        Method to create a record
        Parameters:
        item - data object representing the record.
        Returns:
        A future
      • putItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> putItem​(@NonNull
                                                                 ENTITY_TYPE item,
                                                                 rx.functions.Action2<ENTITY_TYPE,​Map<String,​software.amazon.awssdk.services.dynamodb.model.AttributeValue>> ttlAction)
        Parameters:
        item - Item being saved. This is an upsert operation
        ttlAction - TTL function
        Returns:
        Record being saved
      • putItem

        default reactor.core.publisher.Flux<ENTITY_TYPE> putItem​(@NonNull
                                                                 List<ENTITY_TYPE> items)
        Method to create a list of records
        Parameters:
        items - the list of records to be updated
        Returns:
        A future
      • updateItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> updateItem​(@NonNull
                                                                    ENTITY_TYPE item)
        Updates a record with the new values set in the entity
        Parameters:
        item - item updated
        Returns:
        updated item
      • updateItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> updateItem​(@NonNull
                                                                    PrimaryKey primaryKey,
                                                                    @NonNull
                                                                    Map<String,​Object> updatedValues)
        Parameters:
        primaryKey - Hash Key and Sort Keys
        updatedValues - Updates
        Returns:
        A future representing the execution of the method
      • updateItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> updateItem​(@NonNull
                                                                    UpdateItem updateItem)
        Parameters:
        updateItem - Updated Values
        Returns:
        A future representing the execution of the method
      • updateItem

        default reactor.core.publisher.Flux<ENTITY_TYPE> updateItem​(@NonNull
                                                                    List<UpdateItem> updateItems)
        Method updates a list of records/documents. Please note that DynamoDb as of today does not support a batch update. This method updates the records one at a time. It will do a batch update once DynamoDB/AWS SDK adds support without forcing the client application to make a change.
        Parameters:
        updateItems - updateItem Updated Values
        Returns:
        A future representing the execution of the method
      • updateItems

        default reactor.core.publisher.Flux<ENTITY_TYPE> updateItems​(String keyValue,
                                                                     @NonNull
                                                                     List<? extends PatchUpdate> patchUpdates,
                                                                     rx.functions.Func1<PatchUpdate,​UpdateItem> convertFunc)
        Method updates a list of records/documents. Please note that DynamoDb as of today does not support a batch update. This method updates the records one at a time. It will do a batch update once DynamoDB/AWS SDK adds support without forcing the client application to make a change.
        Parameters:
        keyValue - Key Value
        patchUpdates - PatchUpdate list
        convertFunc - Function to convert PatchItem to UpdateItem
        Returns:
        Updated records
      • deleteAllItems

        default reactor.core.publisher.Flux<ENTITY_TYPE> deleteAllItems​(@NonNull
                                                                        List<ENTITY_TYPE> items)
        Method to remove a list of records
        Parameters:
        items - List of items to be removed
        Returns:
        A future
      • batchWrite

        default reactor.core.publisher.Flux<ENTITY_TYPE> batchWrite​(List<ENTITY_TYPE> putItems,
                                                                    List<ENTITY_TYPE> deleteItems)
        Method to remove a list of records
        Parameters:
        putItems - List of items to be added
        deleteItems - List of items to be removed
        Returns:
        A future
      • deleteItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> deleteItem​(@NonNull
                                                                    ENTITY_TYPE item)
        Method to remove a specific record
        Parameters:
        item - Item to be removed
        Returns:
        A future
      • saveItems

        default reactor.core.publisher.Flux<ENTITY_TYPE> saveItems​(@NonNull
                                                                   List<ENTITY_TYPE> item)
        Method to create a record
        Parameters:
        item - data object representing the record.
        Returns:
        A future
      • saveItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> saveItem​(@NonNull
                                                                  ENTITY_TYPE item)
        Method to create a record
        Parameters:
        item - data object representing the record.
        Returns:
        A future
      • saveItem

        default reactor.core.publisher.Mono<ENTITY_TYPE> saveItem​(ENTITY_TYPE item,
                                                                  rx.functions.Action2<ENTITY_TYPE,​Map<String,​software.amazon.awssdk.services.dynamodb.model.AttributeValue>> ttlAction)
        Parameters:
        item - Item being saved. This is an insert operation.
        ttlAction - TTL action
        Returns:
        Item being saved