1)DynamoDBには、List
属性のサイズを取得する機能がありません。配列要素のサイズは、length
関数を使用してクライアント側で見つけることができます。
data.Item.records.length
は、配列要素records
の長さを示します。 records
はDynamoDBテーブルのリストです。
docClient.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
console.log(data.Item[0].records.length);
}
});
2)サブアレイを登録すると、構文は次のようになります。 DynamoDBは'records[1-3]'
のような範囲をサポートしていません。
ProjectionExpression: 'records[0], records[1]',
3)DynamoDBには、リスト内の最後の項目を取得する機能がありません。しかし、あなたはクライアント側でそれを得ることができます。私はrecords
のリストを持っています。私は最後の要素を持っていますitemValue.records[itemValue.records.length - 1]
docClient.query(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err,
null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
data.Items.forEach(function(itemValue) {
console.log (itemValue.records[itemValue.records.length - 1]);
});
}
});
ありがとう、それは役に立ちます。配列の最後の項目を返す投影式はありますか? – Lucio