On the CLI this works:
aws dynamodb query
--table-name BatchTable
--index-name completed_index
--key-condition-expression "completed = :completed"
--expression-attribute-values '{":completed":{"N":"0"}}'
Result:
{
"Items": [
{
"completed": {
"N": "0"
},
[snip]
But in Lambda this doesn’t:
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient, GetCommand } from '@aws-sdk/lib-dynamodb';
const ddbClient = new DynamoDBClient({});
const ddbDocClient = DynamoDBDocumentClient.from(ddbClient);
const ddbCommand = new GetCommand({
TableName: 'BatchTable',
IndexName: 'completed_index',
KeyConditionExpression: 'completed = :completed',
ExpressionAttributeValues: {
':completed': '0',
},
});
const ddbResponse = await ddbDocClient.send(ddbCommand);
Result:
1 validation error detected: Value null at 'key' failed to satisfy constraint: Member must not be null
I can’t for the life of me figure out why.