iam created a table in amazon dynamoDB using web console. this is my table structure after adding some data.
101 | manaf | haaaai
102 | manaf | hello
I need to get the data between two res limits.
this is my code in js.
var AWS = require("aws-sdk");
AWS.config.update({
region: "regionName",
});
var docClient = new AWS.DynamoDB.DocumentClient()
var table = "testTable";
var params = {
TableName: table,
FilterExpression :['userid = :id','res >= :val1','res <= :val2'],
ExpressionAttributeValues : {':id' : 'manaf','res':101, 'res':102}
};
docClient.scan(params, function(err, data) {
if (err) console.log(err);
else console.log(data);
});
But i got error like this.
{ [InvalidParameterType: Expected params.FilterExpression to be a string]
message: 'Expected params.FilterExpression to be a string',
code: 'InvalidParameterType',
time: Thu May 19 2016 17:24:57 GMT+0530 (IST) }
How to add multiple filter options in dynamo db scan method?
Your FilterExpression
is a list. You have to supply a string and concatenate elements using dynamos operators ( OR, AND ).
For example:
FilterExpression: "x = 1 AND y = 2"
From the docs:
The syntax for FilterExpression is identical to that of ConditionExpression. In addition, FilterExpression uses the same comparators, functions, and logical operators as ConditionExpression. For more informatio
You may also need to replace keys and values to avoid error "Attribute is a reserved keyword; " See the docs for more details: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ExpressionPlaceholders.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With