【发布时间】:2021-05-07 16:09:43
【问题描述】:
我正在尝试按排序和键对我的 dynamo db 结果进行排序,并且还根据排序键获取一系列值,并且我不断收到无效的键条件表达式错误。基本上我试图根据我的排序键获取一系列值并对它们进行排序。
保存的数据库项目示例:
{
id: ORDER_287d6df3-bd9f-472d-87ef-ee9b810b5874
issued_at: 2021-05-07T15:09:11.894Z
base_cur: NGN
orderRate(GSI): SELL#500
quantity: 300
quantityRemaining: 300
quantityRemoved: 0
quote_cur: GBP
rate: 500
side: SELL
ticker(GSI): GBP#NGN
}
我尝试过的:
const params = {
TableName: process.env.ORDERS_TABLE_NAME,
IndexName: 'ticker_orderRate',
KeyConditionExpression: `ticker = :ticker and orderRate between :maxRate and :baseRate`,
ExpressionAttributeValues: {
':ticker': `${quote_cur}#${base_cur}`,
':maxRate': `${side === 'BUY' ? 'SELL' : 'BUY'}#${rate}`,
':baseRate': `${side === 'BUY' ? 'SELL' : 'BUY'}#0.00`,
}
};
速率是来自 SNS 主题的数字。
错误信息:
ERROR: ValidationException: Invalid KeyConditionExpression: The BETWEEN operator requires upper bound to be greater than or equal to lower bound; lower bound operand: AttributeValue: {S:BUY#620}, upper bound operand: AttributeValue: {S:BUY#0.00}
有没有办法在查询数据库时将汇率和基本汇率转换为数字?还有我如何按升序排序? 感谢您的帮助
【问题讨论】:
-
您收到的实际错误消息是什么?您如何查询这些数据(即客户端是什么)?
-
我已将错误消息添加到问题中,并且我在 AWS 开发工具包中使用了 javascript
标签: javascript typescript amazon-web-services lambda amazon-dynamodb