AWS Developer Tools Blog
Introducing DynamoDB Document API (Part 1)
Amazon DynamoDB has recently announced the support of storing entire JSON-style document as single DynamoDB items. What is as exciting is that the AWS SDK for Java has come up with a new Document API that makes it easy and simple to access all the feaures of Amazon DynamoDB, including the latest document support, but with less code!
The new Document API is designed from the ground up to be the next generation of API for accessing DynamoDB. It has an object-oriented API that provides full access to all the DynamoDB features including JSON data support, use of Document Path to access part of a document, new data types such as Map, List, etc. The best part is, the resultant code is a lot less verbose, and is therefore both easier to write and read.
Alright, enough talking. Perhaps the new API can best be illustrated with an example. Here I took the liberty of borrowing the code from a previous blog, Using Improved Conditional Writes in DynamoDB, and rewrite it using the new API. To begin with, the original code is copied here:
Now, let’s rewrite the same code using the DynamoDB Document API:
As you see, the new Document API allows the direct use of plain old Java data types and has less boilerplate. In fact, the Dynamo Document API can be used to entirely subsume what you can do with the low level client (i.e. AmazonDynamoDBClient) but with a much cleaner programming model and less code.
I hope this has whet your appetite in harnessing the power of Amazon DynamoDB using the Document API. To see more examples, feel free to play with the code sample in the A-Z Document API quick-start folder at github, or check out the AWS blog.