LoginSignup
7
2

More than 3 years have passed since last update.

DynamoDBで一部の属性のみを取得する(プロジェクション式)--projection-expression

Posted at

テーブルからデータを読み取るには、GetItem、Query や Scan などのオペレーションを使用します。Amazon DynamoDB は、デフォルトですべての項目属性を返します。すべての属性ではなく、一部の属性のみを取得するには、プロジェクション式を使用します。

key.json
{
    "Id": { "N": "123" }
}

まずは、--projection-expression なしですべての項目を呼び出してみる。

$ aws dynamodb get-item \
--table-name testprojectionexpression \
--key file://key.json

{
    "Item": {
        "Description": {
            "S": "test"
        },
        "name": {
            "S": "sato"
        },
        "Id": {
            "N": "123"
        }
    }
}

--projection-expression で Description のみを呼び出してみる。

$ aws dynamodb get-item --table-name ProductCatalog \
--key file://key.json \
--projection-expression "Description"

{
    "Item": {
        "Description": {
            "S": "test"
        }
    }
}
7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2