Package org.leo.aws.ddb.repositories
Interface DynamoDbRepository<ENTITY_TYPE>
-
public interface DynamoDbRepository<ENTITY_TYPE>
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PAGE_SIZE
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default reactor.core.publisher.Flux<ENTITY_TYPE>batchWrite(List<ENTITY_TYPE> putItems, List<ENTITY_TYPE> deleteItems)Method to remove a list of recordsdefault reactor.core.publisher.Flux<ENTITY_TYPE>deleteAllItems(List<ENTITY_TYPE> items)Method to remove a list of recordsdefault reactor.core.publisher.Mono<ENTITY_TYPE>deleteItem(ENTITY_TYPE item)Method to remove a specific recorddefault software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientdynamoDbClient()default reactor.core.publisher.Flux<ENTITY_TYPE>findAll()Get all records.default reactor.core.publisher.Flux<ENTITY_TYPE>findAll(int limit)Get all recordsdefault reactor.core.publisher.Flux<ENTITY_TYPE>findAll(Expr expr)default reactor.core.publisher.Flux<ENTITY_TYPE>findAll(Expr expr, int limit)default reactor.core.publisher.Flux<ENTITY_TYPE>findBy(PrimaryKey... primaryKeys)default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKey(Object hashKeyValue)Returns a list of values matching hash key value passed.default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKey(String hashKeyName, Object hashKeyValue)Returns a list of values matching hash key value passed.default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKey(String hashKeyName, Object hashKeyValueObj, String indexName, Expr expr)Returns a flux representing a list of values which matches the hash key value passeddefault reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKey(String hashKeyName, Object hashKeyValue, Page page)Returns a flux (list) of values matching hash key value passed.default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKey(String hashKeyName, Object hashKeyValueObj, Page page, String indexName, Expr expr)Returns a flux representing a list of values which matches the hash key value passeddefault reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKey(String hashKeyName, Object hashKeyValueObj, Expr expr)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.default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKeyAndRangeKeyStartsWith(String hashKey, Object hashKeyValueObj, String rangeKey, String rangeKeyValue, String indexName, Expr expr)default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKeyAndRangeKeyStartsWith(String hashKey, Object hashKeyValueObj, String rangeKey, String rangeKeyValue, Page page)Returns a list of entities whose has hash key matches the value sent and the range key starts with the value sent.default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKeyAndRangeKeyStartsWith(String hashKey, Object hashKeyValueObj, String rangeKey, String rangeKeyValue, Page page, String indexName, Expr expr)default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKeyAndRangeKeyStartsWithPagination(String hashKey, Object hashKeyValueObj, String rangeKey, String rangeKeyValue, Page page)default reactor.core.publisher.Flux<ENTITY_TYPE>findByHashKeyAndRangeKeyStartsWithPagination(String hashKey, Object hashKeyValueObj, String rangeKey, String rangeKeyValue, Page page, String indexName, Expr expr)default reactor.core.publisher.Mono<ENTITY_TYPE>findByPrimaryKey(Object hashKeyValue)default reactor.core.publisher.Mono<ENTITY_TYPE>findByPrimaryKey(Object hashKeyValue, Object rangeKeyValue)default reactor.core.publisher.Mono<ENTITY_TYPE>findByPrimaryKey(PrimaryKey primaryKey)Returns a record which matches the primary key passeddefault reactor.core.publisher.Flux<ENTITY_TYPE>findByPrimaryKeys(List<PrimaryKey> primaryKeys)default reactor.core.publisher.Flux<ENTITY_TYPE>findBySecondaryIndex(String indexName, Object hashKeyValueObj)Queries by GSI name and the hash key value used for the indexdefault reactor.core.publisher.Flux<ENTITY_TYPE>findBySecondaryIndex(String indexName, Object hashKeyValueObj, Object rangeKeyValue)default reactor.core.publisher.Flux<ENTITY_TYPE>findBySecondaryIndex(String indexName, Object hashKeyValueObj, Object rangeKeyValue, Expr expr)default reactor.core.publisher.Flux<ENTITY_TYPE>findBySecondaryIndex(String indexName, Object hashKeyValueObj, Expr expr)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])default Map<String,?>getFieldMappings(ENTITY_TYPE item, boolean includeNullValues)Returns map representation without primary keysdefault StringgetHashKeyName()default Class<ENTITY_TYPE>getParameterType()default PrimaryKeygetPrimaryKey(ENTITY_TYPE item)default StringgetRangeKeyName()default reactor.core.publisher.Mono<ENTITY_TYPE>putItem(ENTITY_TYPE item)Method to create a recorddefault reactor.core.publisher.Mono<ENTITY_TYPE>putItem(ENTITY_TYPE item, rx.functions.Action2<ENTITY_TYPE,Map<String,software.amazon.awssdk.services.dynamodb.model.AttributeValue>> ttlAction)default reactor.core.publisher.Flux<ENTITY_TYPE>putItem(List<ENTITY_TYPE> items)Method to create a list of recordsdefault reactor.core.publisher.Mono<ENTITY_TYPE>saveItem(ENTITY_TYPE item)Method to create a recorddefault 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)default reactor.core.publisher.Flux<ENTITY_TYPE>saveItems(List<ENTITY_TYPE> item)Method to create a recorddefault reactor.core.publisher.Mono<ENTITY_TYPE>updateItem(ENTITY_TYPE item)Updates a record with the new values set in the entitydefault reactor.core.publisher.Flux<ENTITY_TYPE>updateItem(List<UpdateItem> updateItems)Method updates a list of records/documents.default reactor.core.publisher.Mono<ENTITY_TYPE>updateItem(PrimaryKey primaryKey, Map<String,Object> updatedValues)default reactor.core.publisher.Mono<ENTITY_TYPE>updateItem(UpdateItem updateItem)default reactor.core.publisher.Flux<ENTITY_TYPE>updateItems(String keyValue, List<? extends PatchUpdate> patchUpdates, rx.functions.Func1<PatchUpdate,UpdateItem> convertFunc)Method updates a list of records/documents.
-
-
-
Field Detail
-
DEFAULT_PAGE_SIZE
static final int DEFAULT_PAGE_SIZE
- See Also:
- Constant Field Values
-
-
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
-
getPrimaryKey
default PrimaryKey getPrimaryKey(ENTITY_TYPE item)
-
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- entityincludeNullValues- 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 NamehashKeyValue- 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 NamehashKeyValue- 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 tablehashKeyValueObj- The value of the Hash keyindexName- 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 tablehashKeyValueObj- The value of the Hash keyindexName- 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 tablehashKeyValueObj- The value of the Hash keyrangeKey- 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 tablehashKeyValueObj- The value of the Hash keyrangeKey- 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 tablehashKeyValueObj- The value of the Hash keyrangeKey- Range key.rangeKeyValue- Range Key ValueindexName- Index nameexpr- 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 tablehashKeyValueObj- The value of the Hash keyrangeKey- Range key.rangeKeyValue- Range Key ValueindexName- Index nameexpr- 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 tablehashKeyValueObj- The value of the Hash keyrangeKey- Range key.rangeKeyValue- Range Key Valuepage- 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 NamehashKeyValueObj- Hash Key ValuerangeKey- Range Key NamerangeKeyValue- Range Key Valuepage- PageindexName- Index nameexpr- 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 GSIhashKeyValueObj- 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 indexhashKeyValueObj- hash key valuerangeKeyValue- 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 GSIhashKeyValueObj- Hash Key Valueexpr- 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 GSIhashKeyValueObj- Hash Key ValuerangeKeyValue- Range Key Valueexpr- 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 Expressionlimit- 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 operationttlAction- 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 KeysupdatedValues- 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 ValuepatchUpdates- PatchUpdate listconvertFunc- 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 addeddeleteItems- 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
-
-