Reputation: 1404
Here is my code to fetch all elements that has a text as 'Make a dinner'.
const params = {
TableName: 'todos',
KeyConditionExpression: 'todoName = :t',
ExpressionAttributeValues: { ':t': 'Make a dinner' }
};
db.scan(params, (err, data) => {
if (err)
console.log(err);
});
I get this error:
Query condition missed key schema element: todo_id
What is the reason for this error? How to avoid it? I have only primary key in my table, no sort key.
Upvotes: 13
Views: 25159
Reputation: 201103
It sounds like todo_id
is your primary key. You are trying to query on todoName
. You can't query on non-key fields.
You either need to run a scan
instead of a query
, or change your query to use todo_id
instead of todoName
, or change your table primary key to be todoName
, or add a global secondary index on todoName
.
Upvotes: 23