My Lambda script is:
var AWS = require("aws-sdk");
var DOC = require("dynamodb-doc");
AWS.config.update({region: "us-west-1"});
var docClient = new DOC.DynamoDB();
var dynamodb = new AWS.DynamoDB();
exports.handler = function(event, context) {
var params = {};
params.TableName = "Emails";
params.ConditionalOperator = "AND";
params.ScanFilter = {
Machinekey:{
ComparisonOperator:"EQ",
AttributeValueList: [{S: "okok"}]
}
};
params.Select= "COUNT";
//params.IndexName = "Machinekey-index";
//params.KeyConditions = docClient.Condition("EmailId", "NOT_NULL");
//params.QueryFilter = docClient.Condition("Machinekey", "EQ","ARUZE-010415_15112442NLHIYTLY-A23V3.9");
dynamodb.scan(params, function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
//console.log(data);
context.succeed(data.Count);
}
});
};
Result of Execution logs:
[ValidationException: ConditionalOperator can only be used when Filter or Expected has two or more elements] message: 'ConditionalOperator can only be used when Filter or Expected has two or more elements', code: 'ValidationException', time: Wed Jun 10 2015 03:12:34 GMT+0000 (UTC), statusCode: 400, retryable: false,
Please, help me!
You specify
ConditionalOperator = "AND";
, but you do not need this with your current query that contains only one condition (Machinekey == "okok"). You would only need theConditionalOperator
if you had two or more conditions.Try commenting out the
ConditionalOperator
and trying it again: