DynamoDB scan not finding record

0

I have a lambda node function that is performing a scan against DynamoDB, it does not return an item.

var params = {
        TableName: REFERRER_TABLE,
        FilterExpression: "messageId = :a",
        ExpressionAttributeValues: {
          ":a": {
            S: messageId
          }
        }
};

dynamoDb.scan(params, function(error, leadData) { ...

returns:

{
    "body": {
        "Items": [],
        "Count": 0,
        "ScannedCount": 2
    },
    "query": {
        "TableName": "lead-data-dev",
        "FilterExpression": "messageId = :a",
        "ExpressionAttributeValues": {
            ":a": {
                "S": "1aa94a6b-6b54-46e6-838d-5781d223f673"
            }
        }
    }
}

I have tested the params in DynamoDB JavaScript Shell and it works expected. I have also successfully tried via AWS CLI

I'm out of ideas. What am I doing wrong?

Edited by: lt-david on Jun 27, 2019 4:21 AM

질문됨 5년 전801회 조회
2개 답변
0

managed to get to the bottom of this:

{
    "body": {
        "Items": [],
        "Count": 0,
        "ScannedCount": 2
    },
    "query": {
        "TableName": "lead-data-dev",
        "FilterExpression": "messageId = :a",
        "ExpressionAttributeValues": {
            ":a":  "1aa94a6b-6b54-46e6-838d-5781d223f673"
        }
    }
}

the ExpressionAttributeValues should not have a type, it's odd that it works on the JavaScript Shell and CLI

답변함 5년 전
0

Hi

I am glad you could fix the query to return items.
You can always refer to our documentation for Scan in node.js, https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.NodeJs.04.html#GettingStarted.NodeJs.04.Scan using which you can understand ways to construct the API parameters.

I hope this helps going forward.

Regard,
Almas

AWS
답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠