Atul
Atul

Reputation: 1590

AWS DynamoDB Scan Operation ScanFilter Not Working

I am running below dynamo DB scan query in AWS

const dynamoDb = require('aws-sdk/clients/dynamodb.js');
const dynmoDBClient = new dynamoDb.DocumentClient({ region: "REGION"});
let params = {
   "TableName":"Users",
   "ScanFilter":{
      "name":{
         "AttributeValueList":[
            {
               "S":""
            }
         ],
         "ComparisonOperator":"GT"
      }
   },
   "Select":"ALL_ATTRIBUTES"
}


let result = null;
result = await dynmoDBClient.scan(params).promise();

When I run the query , I get below error -

ERROR occurred while querying data from DB : 
{"message":"One or more parameter values were invalid:
 ComparisonOperator GT is not valid for M AttributeValue type"}
 

As per table definition , name attribute is of type S (string) and not M (map)

But I am still getting this error.

Can anybody please help here as I am not getting what is the issue here ?

Upvotes: 0

Views: 716

Answers (1)

hunterhacker
hunterhacker

Reputation: 7142

AWS maintains sample code of core DynamoDB operations in various languages. Here's their sample for Scan in Node.js:

https://github.com/aws-samples/aws-dynamodb-examples/blob/master/DynamoDB-SDK-Examples/node.js/WorkingWithScans/scan-parallel-segments.js

ScanFilter is legacy so don't go there.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ScanFilter.html

Upvotes: 1

Related Questions