DynamoDB Support for JSON Documents

二次信任 提交于 2020-01-04 21:45:29

问题


AWS DynamoDB recently released support for JSON documents per: http://aws.amazon.com/blogs/aws/dynamodb-update-json-and-more/

Questions:

1) How can I use this if I am making a request directly to the service? Do I just set the M value to the entire json object?

2) Can indexes be included in the JSON document? Will DynamoDB be able to figure this out?


回答1:


As documented in the link you included in your question, the support for JSON is built into many of the AWS SDKs rather than being entirely implemented in DynamoDB. Using DynamoDB's new Map and List types for example, a JSON structure is mapped to DynamoDB types and structures in a predictable way. So, no, you would not set an M value to the entire JSON object (unless that's the final structure you wanted).

Indexes continue to be available using the standard access patterns as documented here for example.

You would need to use one of the SDKs or provide your own service layer to map a JSON document to a DynamoDB item.

Currently (November 2014), the AWS-SDK for JavaScript (which includes NodeJS) does not have built-in support for JSON data. However, it is available through an AWS-Labs project here. You'll see in that code that the document client code attaches to an event so that all of the data can be formatted (from JSON to native DynamoDB):

request.on("extractData", f.formatOutput);

Where f is an instance of their DynamoDBFormatter.




回答2:


The awslabs project looks really promising and full featured, but it's not currently published to npm (2014 December).

node-dynamodb

That looks really good, wish I had found it sooner.

Before I wrote a more simple JSON => DynamoDb conversion module.

dynamodb-marshaler



来源:https://stackoverflow.com/questions/26697538/dynamodb-support-for-json-documents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!