ラムダAWSを使用してDynamoDBから条件を満たす最初の10項目を取得しようとします。私はリミットパラメータを使用しようとしていたが、それは(そのウェブサイト上の根拠)AWS DynamoDB Node.jsスキャン - 一定数の結果
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#scan-property
「最大項目数を評価する(必ずしも一致するアイテムの数)」です。
私の状態を満たす最初の10項目を取得するには? DynamoDBのはScannedCount
とCount
の間になり区別:
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",
},
ExpressionAttributeValues: {
":lower_lon": {"N": event.low_lon},
":higher_lon": {"N": event.high_lon}, //event.high_lon}
":lower_lat": {"N": event.low_lat},
":higher_lat": {"N": 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);
}
});
};
何を試しましたか?あなたのコードはどのように見えますか?エラーメッセージが表示されましたか? – SunSparc
私のコードには問題ありません。私はちょうどその問題を解決する方法を知らない。ちょうど私の質問にそれを含める場合。 –
制限が動作する – Shibashis