Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

io.github.normandesjr:prefix-dynamodb-mapper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io.github.normandesjr:prefix-dynamodb-mapper

Decorator for DynamoDBMapper that will help you add prefix to your attributes

  • 0.1.1
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Prefix DynamoDB Mapper

Motivation

Sometimes you need to add some prefixes to attributes when using DynamoDB.

The goal of this project is to keep this task as simple as possible, using annotations.

How to use it

Configuration

The lib is released at Maven Central, so you can just add the dependency at your pom.xml

<dependency>
	<groupId>io.github.normandesjr</groupId>
	<artifactId>prefix-dynamodb-mapper</artifactId>
	<version>0.1.0</version>
</dependency>

We will decorate the original DynamoDBMapper with the PrefixKeyDynamoDBMapper as follow:

@Bean
public PrefixKeyDynamoDBMapper dynamoDBMapper(AmazonDynamoDB amazonDynamoDB) {
    return new PrefixKeyDynamoDBMapper(amazonDynamoDB, new DynamoDBMapper(amazonDynamoDB));
}

Annotation

On a get method add the @DynamoDBPrefix with the prefix, as the following code:

@DynamoDBPrefix("PRODUCT_")
@DynamoDBHashKey(attributeName = "pk")
public String getSku() {
    return sku;
}

Attention, it only works on getters methods and it's mandatory to have the setter method too.

Saving

Create the object that you would like to save and using the decorator PrefixKeyDynamoDBMapper the prefix will be added for you.

Product product = new Product("AAA111");
dynamoDBMapper.save(product)

If you check at database you'll see the value "PRODUCT_AAA111" as the value of "pk" data.

Loading

It's mandatory to use @DynamoDBHashKey and @DynamoDBRangeKey with DynamoDBMapper.load(Class clazz, Object hashKey, Object rangeKey).

Product product = dynamoDBMapper.load(Product.class, "AAA1111", "MacBook Pro");

Supposing you have hashKey with PROD_ prefix and rangeKey with "PROD_NAME_ prefix the returned product will not have these prefixes.

Developers

Check quality

There is a docker-compose.yml to start a sonarqube.

./mvnw clean install sonar:sonar

Check at localhost:9000 the report.

Release

If your version is a release version (does not end in -SNAPSHOT):

./mvnw clean deploy

FAQs

Package last updated on 22 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc