【发布时间】:2021-09-22 04:20:50
【问题描述】:
我有一个 dynamodb 表,其结构类似于:
{
Type: 'AWS::DynamoDB::Table',
Properties: {
KeySchema: [
{
AttributeName: 'itemID',
KeyType: 'HASH'
}
],
AttributeDefinitions: [
{
AttributeName: 'itemID',
AttributeType: 'S'
},
{
AttributeName: 'label',
AttributeType: 'S'
}
],
GlobalSecondaryIndexes: [
{
IndexName: 'byLabel',
KeySchema: [
{
AttributeName: 'label',
KeyType: 'HASH'
}
],
Projection: {
ProjectionType: 'ALL'
}
}
]
}
}
对于我的一种访问模式,我想获取包含带有特定子字符串的标签的所有数据。我对 dynamodb 很陌生,所以我不确定实现这一目标的最佳方法。
我让它为下面的 equals 工作。但是我更喜欢更多结果,因此返回包含输入的数据将是理想的。
当前请求 VTL 模板:
{
"version": "2018-05-29",
"operation": "Query",
"query": {
"expression": "label = :label",
"expressionValues": {
":label": $util.dynamodb.toDynamoDBJson($context.arguments.label)
}
},
"index": "byLabel",
}
我正在寻找有关通常如何使用 dynamodb 实现来完成此操作的建议。
【问题讨论】:
标签: amazon-dynamodb vtl