amazon-archives/aws-sdk-react-native

DynamoDB.DocumentClient

Closed this issue · 2 comments

Documents returned by the RN DynamoDB client include explicit types ("S", "L", "M", etc.) and nested values. Working with JS-typed values directly would be easier, as with the JavaScript SDK's DocumentClient: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html

The react native sdk uses the AWS Android and iOS sdk. which currently do not support DynamoDB document client. Once those sdk adds support for the high level we will in-turn add it to the react native sdk.

Karthik, your answer is rather unsatisfying. Here is the result of my own investigation, which I hope will lead to this issue being resolved:

I can't speak of the Android SDK, but the iOS SDK sure does implement high-level integration with DynamoDB. However, because Swift/ObjC are statically typed languages, the idiomatic best practice is to define model classes (inheriting from AWSDynamoDBObjectModel and implementing the AWSDynamoDBModeling protocol).

But that doesn't help our case. You'd still need to map the Swift/ObjC types to JavaScript types. In my opinion, the way to go is to simply use the Converter from the AWS JavaScript SDK: https://github.com/aws/aws-sdk-js/blob/master/lib/dynamodb/converter.js