如何在DynamoDB查询操作上指定多个条件?
var params = {
TableName: "liveTraining",
KeyConditionExpression: "#ContentId = :contentId and #CompanyId = :companyId and #Status=:status",
ExpressionAttributeNames:{
"#ContentId": "ContentId",
"#CompanyId": "CompanyId",
"#Status": "Status"
},
ExpressionAttributeValues: {
":contentId": contentId,
":companyId": companyId,
":status": 'Active'
}
};
return new Promise((resolve, reject) => {
dynamoDB.query(params, function (error, response) {
if (error) {
console.log('Unable to fetch data', JSON.stringify(error, null, 2));
} else {
console.log('fetched data', response);
}
})
});
当我使用AND运算符指定两个以上条件时,出现错误:
Unable to fetch data {
"message": "Conditions can be of length 1 or 2 only",
"code": "ValidationException",
"time": "2019-04-12T06:53:34.766Z",
"requestId": "MOE9FDN6I62NLROVPPTDMS5V2JVV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 29.17802723976769
}