9.2: Implement your data model at the very boundary of your application

In the previous example, we printed out the customers that were saved in the DynamoDb table. The response includes the indexing attributes and if you are not using "@aws-sdk/lib-dynamodb" you'll notice that each attribute value is a map with a single key and value indicating the DynamoDB type and the value for the attribute.

Both of these facts will make it messy to work with DynamoDB items in the business logic portion of your application. You’ll be grabbing nested properties, performing proper type conversions, and adding indexing attributes before saving your items.

To avoid this problem, implement your data model at the boundary of your application. Within the core of your application, your application objects should have the main attributes that are relevant to your business logic. For example, if you have a function called getUser('userId') the returned value from this function is a User object that is meaningful and useful to my application.

All interaction with DynamoDB should be handled in the data module that is at the boundary of your application.