8

Trying to use KeyConditionExpression as per the dynamodb api document using nodejs sdk. KeyConditionExpression is not supported with nodejs SDK.

Here is what i did

Created a Table with Hash and Range.

Table : TABLE1
Hash Attribute Name : Provider ( String) 
Range Attribute Key : ScheduledEndTime ( Number ) // In Milli Seconds

Here is payload to trigger dynamo DB query:

{
  TableName: 'TABLE1',
  ConsistentRead: true,
  Select: "ALL_ATTRIBUTES",
  KeyConditionExpression: 'Provider = :v_provider AND ScheduledEndTime > :v_scheduledEndTime',
  ExpressionAttributeValues: {
    ":v_provider": {
      S: "amazon"
    },
    ":v_scheduledEndTime": {
      N: "10"
    }
  }
}; 

But, the above payload thrown below errors

[Error: MultipleValidationErrors: There were 2 validation errors:
* MissingRequiredParameter: Missing required key 'KeyConditions' in params
* UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in    params]
[Error: MultipleValidationErrors: There were 2 validation errors:
* MissingRequiredParameter: Missing required key 'KeyConditions' in params
* UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params]

As per the document, if we use KeyConditionExpression, SDK should not consider the KeyConditions key and I tried with latest nodejs sdk as well. Is there any thing wrong in the payload pattern ?

1 Answer 1

4

I think some places (Lambda in particular) give you the wrong version of the API by default. When I was running into this problem, replacing my dynamo instance with the following fixed the problem:

var AWS = require("aws-sdk");
var dynamo = new AWS.DynamoDB({apiVersion: '2012-08-10'}); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.