Node.js Question

Node.js- scan DynamoDB AWS- adding parameters

I get data from dynamoDB with Lambda AWS. I try to add parameter to my parameters which I send to Lambda from android app:

if (typeof event.high_lat != "undefined") {
params.ExpressionAttributeValues = event.high_lat;

But I get an error:

[InvalidParameterType: Expected params.ExpressionAttributeValues to be a map]
message: 'Expected params.ExpressionAttributeValues to be a map',

Anyone know how to solve it?

My whole code:

var AWS = require('aws-sdk');
var db = new AWS.DynamoDB();

exports.handler = function(event, context) {

var params = {
TableName: "Events", //"StreamsLambdaTable",
ProjectionExpression: "ID, description, endDate, imagePath, locationLat, locationLon, #nm, startDate, #tp, userLimit", //specifies the attributes you want in the scan result.
FilterExpression: "locationLon between :lower_lon and :higher_lon and locationLat between :lower_lat and :higher_lat",
ExpressionAttributeNames: {
"#nm": "name",
"#tp": "type",

ExclusiveStartKey: {
"ID": {"S": event.LastEvaluatedKey}

ExpressionAttributeValues: {
":lower_lon": {"N": event.low_lon},
":higher_lon": {"N": event.high_lon},
":lower_lat": {"N": event.low_lat}

if (typeof event.high_lat != "undefined") {
params.ExpressionAttributeValues = event.high_lat;

db.scan(params, function(err, data) {
if (err) {
console.log(err); // an error occurred
else {
data.Items.forEach(function(record) {
console.log( + "");


Example of code sent from android app:

"low_lon": "16",
"high_lon": "17",
"low_lat": "52",
"high_lat": "53"

Answer Source

You are blowing away your entire ExpressionAttributeValues map with a single value. You just need to look at the code you wrote above to see how you should add values to the ExpressionAttributeValues map.

Change this:

params.ExpressionAttributeValues = event.high_lat;

To this:

params.ExpressionAttributeValues[":higher_lat"] = {"N": event.high_lat};
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download