我不知道如何解释这一点:
$aws dynamodb scan --table-name Todos-dev
...
{
"Items": [
{
"todoId": {
"S": "9e6e7f0f-97ee-4289-93b9-cb1bf46d5190"
},
"createdAt": {
"S": "2019-12-29T07:11:09.581Z"
},
"name": {
"S": "test4"
},
"userId": {
和
$ aws dynamodb get-item --table-name Todos.dev --key file://key.json
An error occurred (ResourceNotFoundException) when calling the GetItem operation: Requested resource not found
哪里
$ cat key.json
{"todoId": {"S": "9e6e7f0f-97ee-4289-93b9-cb1bf46d5190"}}
serverless.yml
TodosTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: todoId
AttributeType: S
- AttributeName: createdAt
AttributeType: S
- AttributeName: dueDate
AttributeType: S
KeySchema:
- AttributeName: todoId
KeyType: HASH
- AttributeName: createdAt
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
TableName: ${self:provider.environment.TODOS_TABLE}
LocalSecondaryIndexes:
- IndexName: ${self:provider.environment.INDEX_NAME}
KeySchema:
- AttributeName: todoId
KeyType: HASH
- AttributeName: dueDate
KeyType: RANGE
Projection:
ProjectionType: ALL
我收到的消息"提供的键元素与架构不匹配",来自docClient.delete,尝试了多种组合来指定键,没有任何效果。
键元素与架构不匹配
您的表具有哈希键和范围键。您的key.json
文件只有哈希键。使用getItem
时,必须提供完整(哈希和范围(密钥。如果要获取同一哈希键的多个值,或者范围键值未知,则只能使用哈希键,但必须query
api 使用它们。
未找到资源
您在扫描调用中使用Todos-dev
,但在 getItem 调用中使用Todos.dev
。