1
我使用Lambda AWS从dynamoDB获取数据。我尝试参数添加到我的参数,我送拉姆达从Android应用:Node.js-扫描DynamoDB AWS-添加参数
if (typeof event.high_lat != "undefined") {
params.ExpressionAttributeValues = event.high_lat;
}
但我得到一个错误:
[InvalidParameterType: Expected params.ExpressionAttributeValues to be a map]
message: 'Expected params.ExpressionAttributeValues to be a map',
有谁知道如何解决呢?
我的整个代码:从Android应用程序发送的代码
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(
record.name.S + "");
});
context.succeed(data.Items);
}
});
};
例子:
{
"low_lon": "16",
"high_lon": "17",
"low_lat": "52",
"high_lat": "53"
}
现在我得到这样的错误:{[ValidationException:ExpressionAttributeValues包含无效重点:语法错误;键:“high_lat”] message:'ExpressionAttributeValues包含无效键:语法错误;键:“high_lat”', –
对不起,我错过了一些语法。看到我更新的答案。 –
更好,但现在我得到:[ValidationException:无效FilterExpression:表达式中使用的表达式属性值未定义;属性值::higher_lat] message:'无效的FilterExpression:未定义表达式中使用的表达式属性值;属性值::higher_lat', –