[英]AWS DYNAMO DB query with multiple condition
I am trying to fetch details from dynamo db using the bellow query in this DOMAIN and SERVICE are just key(non primary key) 我正在尝试使用此域中的以下查询从dynamo db获取详细信息,而SERVICE只是键(非主键)
let params = {
TableName: asset_table,
ConsistentRead: true,
ProjectionExpression: 'ID,SERVICE',
KeyConditionExpression: "DOMAIN = :service_name AND SERVICE EQ :service_domain",
ExpressionAttributeValues: {
":service_name": {"S":service },
":service_domain": {"S":domain}
}
};
docClient.scan(params, (err, data) => {
if (err) {
onComplete(err);
} else {
console.log(data);
onComplete(null, {
data
});
}
});
this give error as given bellow 这给了下面的错误
{
"message": "ExpressionAttributeValues can only be specified when using expressions: FilterExpression is null",
"code": "ValidationException",
"time": "2019-01-09T09:47:09.180Z",
"requestId": "0G3C02E6251S2H1IQ2LQUTN04JVV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 8.070453867451622
}
The scan
method does not accept a KeyConditionExpression
, in params
. scan
方法不接受params
的KeyConditionExpression
。 Instead you must use the FilterExpression
param. 相反,您必须使用
FilterExpression
参数。
The error is telling you this as it can see your ExpressionAttributeValues
but no FilterExpression
to use them. 错误告诉您这是因为它可以看到您的
ExpressionAttributeValues
但是没有使用它们的FilterExpression
。
According to AWS Docs - Working With Scans : 根据AWS Docs- 使用扫描 :
The syntax for a filter expression is identical to that of a condition expression.
过滤器表达式的语法与条件表达式的语法相同。 Filter expressions can use the same comparators, functions, and logical operators as a condition expression.
过滤器表达式可以使用与条件表达式相同的比较器,函数和逻辑运算符。 For more information, Condition Expressions .
有关更多信息,请参见条件表达式 。
Checkout DDB Docs here for full details on how to use the scan
method. 在此处签出DDB文档以获取有关如何使用
scan
方法的完整详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.