Andrew Goulart Andrew Goulart - 1 year ago 47
Javascript Question

Unable to Access DynamoDB Item's Map attribute values with ExpressionFilter using Javascript

I have the following item in my DynamoDB table:

"quid" : {
"objectType" : {
"document" : {
"M" : {
"externalID" : {
"S" : "12-34-567890"
"eventFormat" : {
"N" : "0"

I'm trying to access that item with the following javascript code

var AWS = require('aws-sdk');

region: "us-west-2"

var docClient = new AWS.DynamoDB.DocumentClient();

var params = {
TableName : "events",
FilterExpression : "document.eventFormat = :nForm",
ExpressionAttributeValues : {":nForm":{"N":"0"}}

docClient.scan(params, function(err, data){
if (err) console.log(err);
else console.log(data);

When I remove the FilterExpression and ExpressionAttributesValues, I get a full scan of my table successfully, and get to see all items contained within. When I add the FilterExpression and the ExpressionAttributesValues, I don't get any results back.

Any help figuring out how to filter my scan by either the externalID or the eventFormat would be greatly appreciated!

Answer Source

Please try with the below params. The data type is not required in ExpressionAttributeValues for scalar numeric values. This worked as expected for me.

var params = {
        TableName: "events",    
        FilterExpression: "document.eventFormat = :nForm",
        ExpressionAttributeValues: {
            ":nForm": 0
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download