我是 aws dynamo db 的新手。我 读过 我们可以在 dynamo db 的模式中设置 M
attributeValue 类型。
但是当我执行下面的代码时
var params = {
TableName: 'product',
KeySchema: [
{
AttributeName: 'productType',
KeyType: 'HASH'
},
{
AttributeName: 'manufacturer',
KeyType: 'SORT'
}
],
AttributeDefinitions: [
{
AttributeName: 'productType',
AttributeType: 'S'
},
{
AttributeName: 'manufacturer',
AttributeType: 'M'
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
}
};
dynamodb.createTable(params, function(err, data) {
console.log(err, data);
});
它不断抛出错误 {"message":"Member must satisfy enum value set: [B, N, S]","code":"ValidationException","time":"2018-02-07T11:20:12.930Z","statusCode":400,"retryable":false}
但是上面的链接说有一个 Map 类型的属性可用。有人能解释一下我怎样才能在 dynamo db 中实现 Map 吗?
原文由 Vaibhav Patil 发布,翻译遵循 CC BY-SA 4.0 许可协议
当您创建一个 dynamodb 表或向其添加索引时,您只能定义索引的属性。换句话说,您只能定义用于分区键或排序键的属性。就像你在你的例子中所做的那样。但是唯一对键有效的属性类型是 S(字符串)、N(数字)和 B(二进制)。映射不是分区键或排序键的有效属性类型,因此您不能在定义表或索引时使用它们。
DynamoDB 是无模式的。除了在创建表时用于索引键的属性外,您不定义任何属性。如果你想在你的表中有一张地图,你只需在放置或更新项目时插入一张。