【发布时间】:2016-10-24 02:06:13
【问题描述】:
我在 API 网关上设置了一个端点,直接与 DynamoDB 对话。
当一个发布请求进来时,我使用正文映射器脚本将我的 url 请求参数映射到 dynamoDB 参数。
我的网址参数
{
"name": "sdaf",
"location": "asdf",
"gender": "male"
}
身体映射脚本
{
"TableName": "sample-table",
"Item": {
"firstName": {
"S": "$input.path('$.name')"
},
"location": {
"S": "$input.path('$.location')"
}
}
}
在我必须将整个对象写入发电机之前,所有这些都可以正常工作。
新网址参数
{
"name": "sdaf",
"location": "asdf",
"gender": "male",
"hobbies": {
"hobby1": {
"startedAt": "<some time>"
},
"hobby2": {
"startedAt": "<some time>"
},
}
}
我不确定在这种情况下身体映射器应该是什么样子? 我试过这个:
身体映射器
{
"TableName": "sample-table",
"Item": {
"firstName": {
"S": "$input.path('$.name')"
},
"location": {
"S": "$input.path('$.location')"
},
"hobbies": {
"M": "$input.path('$.hobbies')"
}
}
}
但不起作用。我想知道是否有办法直接从 api 网关将对象转储到 dynamo 的列中。我知道在两者之间添加一个 lambda 是可能的,但我想避免这种情况。
【问题讨论】:
标签: amazon-dynamodb aws-api-gateway