查询条件缺少关键架构元素:验证错误 [英] Query condition missed key schema element : Validation Error
问题描述
我正在尝试使用以下代码查询 dynamodb
:
I am trying to query dynamodb
using the following code:
const AWS = require('aws-sdk');
let dynamo = new AWS.DynamoDB.DocumentClient({
service: new AWS.DynamoDB(
{
apiVersion: "2012-08-10",
region: "us-east-1"
}),
convertEmptyValues: true
});
dynamo.query({
TableName: "Jobs",
KeyConditionExpression: 'sstatus = :st',
ExpressionAttributeValues: {
':st': 'processing'
}
}, (err, resp) => {
console.log(err, resp);
});
运行此命令时,出现错误提示:
When I run this, I get an error saying:
ValidationException: Query condition missed key schema element: id
我不明白这一点。我已将 id
定义为 jobs
表的分区键,并且需要查找<$ c中的所有作业c $ c>正在处理状态。
I do not understand this. I have defined id
as the partition key for the jobs
table and need to find all the jobs that are in processing
status.
推荐答案
您正在尝试使用条件运行查询不包含主键。这是查询在DynamoDB中的工作方式。您需要扫描您所需要的信息但是,我认为这不是最好的选择。
You're trying to run a query using a condition that does not include the primary key. This is how queries work in DynamoDB. You would need to do a scan for the info in your case, however, I don't think that is the best option.
我认为您想设置一个全局二级索引,并使用该查询查询正在处理
状态。
I think you want to set up a global secondary index and use that to query for the processing
status.
这篇关于查询条件缺少关键架构元素:验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!