DynamoDB Scan Operation with FilterExpression Failing

0

I am performing a scan operation on my DynamoDB table then filtering the result to have items greater than a certain date in NODE.js.

The DynamoDB table formats data like this:

{  
      TableName: tableName,  
      Item: {  
      "visitorID": visitorIDq, // Primary Key  
      "dateID":   dateTime, // What I am filtering the scan for, dateTime is a var I set in js  
      "visitorName": "END OF Q",  
      "employeeName": "END OF Q",  
      "comments":  "END OF Q"  
}  

Current code (node):

  
var params2 = {  
  ExpressionAttributeValues: {  
    ':msID' : {"S": '1554624723801'} // what dateID looks like in milliseconds since epoch  
  },  
  ProjectionExpression: "dateID",  
  FilterExpression: "dateID >= :msID", // dateID (from Table is greater than :msID which is what a value for dateID would look like in the db  
  TableName: "Visitor"   
};  

I am getting this error:

ERROR   Unable to scan the table. Error JSON: {  
  "message": "Invalid FilterExpression: Incorrect operand type for operator or function; operator or function: > operand type: M",  
  "code": "ValidationException",  
  "time": "2019-07-06T02:00:44.569Z",  
  "requestId": "REQUESTID1294743204701HHH443",  
  "statusCode": 400,  
  "retryable": false,  
  "retryDelay": 26.7865000058784  
}  

After some internet searching I am kind of stuck, not really find anybody else with this issue in node. Any ideas?

asked 5 years ago3023 views
1 Answer
0

The correct resolution:

var params2 = {
  ExpressionAttributeValues: {
    ':msID' : dateID
  },
  FilterExpression: "dateID >= :msID", // dateID column in DDB is greater than epoch - 3 months
  TableName: "Visitor"
};

JSON.stringify(params2); //params are stringified here for the scan
answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions