2017-03-04 82 views
0

我是Dynamodb的新手, 我有表名是“用户”,其中有两列,一个是“时间”,另一个是“成本”。 我想根据列名得到排序后的数据, 说如果我提供输入参数为“时间”的前50个记录按递增顺序,并且如果我提供输入参数为“成本”,那么前50个记录。如何根据动态列从dynamodb获取排序数据

我试过这样的事情,但这不起作用。

{ 
    TableName: "User", 
    Limit: 50, 
    ScanIndexForward: false, 
    ExclusiveStartKey: (params.lastEvaluatedKey)? {tripId: {S: String(params.lastEvaluatedKey)}}: null, 
    KeyConditionExpression : 'cost > :costValue', 
    ExpressionAttributeValues : { 
     ':costValue': '1' 
    } 
} 

谢谢先进。

回答

0

不幸的是,Dynamodb对表中的所有属性都没有排序功能。您只能使用ScanIndexForward的排序键对项目排序为true/false。

如果要按排序键以外的属性排序项目,则必须在客户端执行(即,Dynamodb不具备此功能)。