我已经从aws控制台在DynamoDB中创建了一个表。 在为其编写代码时,我无法找到如何声明与分区键关联的排序键
Table: Employee ---------------------------------------------- deptId | Partition key empId | sort key for deptId creationDateTime | global secondary index ----------------------------------------------
班级定义:
@DynamoDBTable(tableName = "Employee") public class Employee { // I have created deptId as partition key @DynamoDBHashKey(attributeName = "deptId") private String dept; // I have created empId as sort key for deptId (partition key) private String empId; // I want to run search query on empId as well @DynamoDBIndexHashKey(attributeName = "empId", globalSecondaryIndexName = "empId-index") @DynamoDBIndexHashKey(attributeName = "creationDateTime", globalSecondaryIndexName = "creationDateTime-index") private String creationDateTime; }
我的问题是我应该使用什么注释以及在声明empId之前如何声明empId是deptId的排序键(这是一个分区键)
我已经搜索过并发现应该使用@DynamoDBIndexRangeKey但该注释确实将排序键与分区键链接
请提前帮助我,
答案 0 :(得分:4)
定义排序键的注释是goRight
if((goRight-1)%870==0){
clearInterval(interval);
// goRight=1; // <-- this is your problem
}
答案 1 :(得分:0)
如果表具有复合主键(分区键和排序键),则必须在类映射中同时指定 DynamoDBHashKey 和 DynamoDBRangeKey 属性。
[DynamoDBTable("Reply")]
public class Reply {
[DynamoDBHashKey] //PrimaryKey
public int ThreadId { get; set; }
[DynamoDBRangeKey] //SortKey
public string Replenishment { get; set; }
// Additional properties go here.
}