Basically, if I know the structure of the data to be stored , It will be effective, but regardless of the payload structure, I cannot make it dynamic.
There are many websites explaining how to use the API gateway as a proxy for DynamoDB.
I found no explanation How to store JSON objects.
Basically I send this JSON to my API endpoint:
{
"entryId":"abc ",
"data":{
"key1":"123",
"key2":123
}
}
If I use the following template for mapping, the data will be correctly placed in my database
{
"TableName": "Events",
"Item ": {
"entryId": {
"S": "abc"
},
"data": {
"M": {
"key1": {
"S": "123"
},
"key2": {
"N": "123"
}
}
}
}
}
However, I don’t know the structure of “data”, so I want the mapping to be dynamic, or even better, I think Avoid any mapping.
I managed to make it dynamic, but all my entries are now of type String:
"data": {"M" : {
#foreach($key in $input.path('$.data').keySet())
"$key": {"S": "$input.path('$.data').get($key)"}#if($foreach.hasNext),#end
#end }
} pre>Can the type be obtained dynamically?
I'm not sure how the API gateway mapping works.Thank you for your help.
Loeb
I have a problem when trying to use the API gateway as a proxy for DynamoDB.
Basically, if I know to store The structure of the data, it will be very effective, but regardless of the payload structure, I cannot make it dynamic.
There are many websites explaining how to use the API gateway as a proxy for DynamoDB.
I found no explanation on how to store JSON objects.
Basically I send this JSON to my API endpoint:
{
"entryId ":"abc",
"data":{
"key1":"123",
"key2":123
}
}
If I use the following template for mapping, the data will be correctly placed in my database
{
"TableName": "Events",
"Item": {
"entryId": {
"S": "abc"
},
"data": {
"M": {
"key1": {
"S": "123"
},
"key2": {
"N": "123"
}
}
}
}
}
However, I don’t know the structure of the "data", so I want the mapping to be dynamic. To better, I want to avoid any mapping.
I managed to make it dynamic, but all my entries are now of type String:
"data ": {"M": {
#foreach($key in $input.path('$.data').keySet())
"$key": {"S": "$ input.path('$.data').get($key)"}#if($foreach.hasNext),#end
#end }
}
Is it possible Dynamic acquisition type?
I'm not sure how the API gateway mapping works.
Thank you for your help.
Loeb
When inserting Dynamodb, you will not avoid some kind of mapping. I recommend using Lambda functions instead of service proxies to provide more control and flexibility when mapping data to the Dynamodb architecture.
< /p>