【发布时间】:2020-11-10 06:58:14
【问题描述】:
我是 DynamoDb 的新手,我确实查看了 AWS 文档以及一些关于 Hash 和 Range 键的问题。毕竟,我仍然不确定它们的确切含义以及您为什么/如何使用它们。谁能用一个例子给我一个简单的解释?
例如,如果我想创建一个带有Name、Genre、Rating 和DateReleased 列的Movie 表。创建 DynamoDb 表的正确方法是什么。在下面的示例中,我有一些 CloudFormation 来尝试创建以下内容,但我不确定我是否正确使用了 KeySchema 属性。任何帮助将不胜感激。
MovieTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: "Name"
AttributeType: "S"
- AttributeName: "Genre"
AttributeType: "S"
- AttributeName: "Rating"
AttributeType: "N"
- AttributeName: "DateReleased"
AttributeType: "S"
KeySchema:
- AttributeName: "Name"
KeyType: "HASH"
- AttributeName: "Genre"
KeyType: "RANGE"
- AttributeName: "Rating"
KeyType: "RANGE"
- AttributeName: "DateReleased"
KeyType: "RANGE"
TimeToLiveSpecification:
AttributeName: ExpireAfter
Enabled: false
SSESpecification:
SSEEnabled: true
【问题讨论】:
标签: node.js amazon-web-services amazon-dynamodb amazon-cloudformation