DynamoDB Error: Member must have length less than or equal to 2; Member must satisfy enum value set: [HASH, RANGE]
DynamoDB Error: Member must have length less than or equal to 2; Member must satisfy enum value set: [HASH, RANGE]
我正在尝试在 DynamoDB 中创建底部显示的 table,但出现此错误。我知道您不能定义多个 PK,但是 GSI-PKs 也是这样吗?我该如何修复错误?
2 validation errors detected: Value '[KeySchemaElement(attributeName=VenueID, keyType=HASH), KeySchemaElement(attributeName=VenueName, keyType=Range), KeySchemaElement(attributeName=CheckInID, keyType=HASH)]' at 'globalSecondaryIndexes.1.member.keySchema' failed to satisfy constraint: Member must have length less than or equal to 2;
Value 'Range' at 'globalSecondaryIndexes.1.member.keySchema.2.member.keyType' failed to satisfy constraint: Member must satisfy enum value set: [HASH, RANGE]
Serverless.yml
resources:
Resources:
BeaconTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.beaconsTable}
AttributeDefinitions:
- AttributeName: BeaconAddr
AttributeType: S
- AttributeName: VenueID
AttributeType: S
- AttributeName: VenueName
AttributeType: S
- AttributeName: CheckInID
AttributeType: S
KeySchema:
- AttributeName: BeaconAddr
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: BeaconAddr-index
KeySchema:
- AttributeName: VenueID
KeyType: HASH
- AttributeName: VenueName
KeyType: Range
- AttributeName: CheckInID
KeyType: HASH
Projection:
ProjectionType: "ALL"
BillingMode: PAY_PER_REQUEST
如果您需要两个属性的索引,请创建两个索引。一个 BeaconAddr-index
索引不能具有 两个 散列属性。
此外,我想知道您是否误解了什么,因为将索引命名为 BeaconAddr-index
而未在 BeaconAddr
上建立索引似乎很奇怪?你打算做什么?
我正在尝试在 DynamoDB 中创建底部显示的 table,但出现此错误。我知道您不能定义多个 PK,但是 GSI-PKs 也是这样吗?我该如何修复错误?
2 validation errors detected: Value '[KeySchemaElement(attributeName=VenueID, keyType=HASH), KeySchemaElement(attributeName=VenueName, keyType=Range), KeySchemaElement(attributeName=CheckInID, keyType=HASH)]' at 'globalSecondaryIndexes.1.member.keySchema' failed to satisfy constraint: Member must have length less than or equal to 2;
Value 'Range' at 'globalSecondaryIndexes.1.member.keySchema.2.member.keyType' failed to satisfy constraint: Member must satisfy enum value set: [HASH, RANGE]
Serverless.yml
resources:
Resources:
BeaconTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.beaconsTable}
AttributeDefinitions:
- AttributeName: BeaconAddr
AttributeType: S
- AttributeName: VenueID
AttributeType: S
- AttributeName: VenueName
AttributeType: S
- AttributeName: CheckInID
AttributeType: S
KeySchema:
- AttributeName: BeaconAddr
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: BeaconAddr-index
KeySchema:
- AttributeName: VenueID
KeyType: HASH
- AttributeName: VenueName
KeyType: Range
- AttributeName: CheckInID
KeyType: HASH
Projection:
ProjectionType: "ALL"
BillingMode: PAY_PER_REQUEST
如果您需要两个属性的索引,请创建两个索引。一个 BeaconAddr-index
索引不能具有 两个 散列属性。
此外,我想知道您是否误解了什么,因为将索引命名为 BeaconAddr-index
而未在 BeaconAddr
上建立索引似乎很奇怪?你打算做什么?