{"id":2128,"date":"2021-09-04T16:34:14","date_gmt":"2021-09-04T07:34:14","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=2128"},"modified":"2022-04-03T15:07:27","modified_gmt":"2022-04-03T06:07:27","slug":"%e3%80%90dynamodb%e3%80%91aws-sdk-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fscan%e3%81%ae%e5%ae%9f%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=2128","title":{"rendered":"\u3010DynamoDB\u3011AWS SDK \u3092\u4f7f\u7528\u3057\u305fscan\u306e\u5b9f\u884c"},"content":{"rendered":"\n<p>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u8907\u6570\u9805\u76ee\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3001query\u3092\u4f7f\u3046\u65b9\u6cd5\u4ee5\u5916\u306bscan\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u4eca\u56de\u306fscan\u3092\u5b9f\u884c\u3057\u3001\u9805\u76ee\u3092\u8907\u6570\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30b9\u30ad\u30e3\u30f3<\/h1>\n\n\n\n<p>\u30b9\u30ad\u30e3\u30f3\u306f\u30d7\u30e9\u30a4\u30de\u30ea\u30ad\u30fc\u306e\u6307\u5b9a\u306f\u5fc5\u8981\u3042\u308a\u307e\u305b\u3093\u3002<br>\u30b9\u30ad\u30e3\u30f3\u306e\u51e6\u7406\u3068\u3057\u3066\u306f\u6307\u5b9a\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5168\u3066\u306e\u9805\u76ee\u3092\u53d6\u5f97\u3057\u3066\u3001\u9805\u76ee\u53d6\u5f97\u306b\u6761\u4ef6\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u9805\u76ee\u306e\u307f\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30c6\u30fc\u30d6\u30eb\u306e\u5185\u5bb9<\/h1>\n\n\n\n<p>Musics\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3057\u3066\u30b9\u30ad\u30e3\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br>\u30c6\u30fc\u30d6\u30eb\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"441\" src=\"https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2021\/08\/table.png\" alt=\"\" class=\"wp-image-2013\" srcset=\"https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2021\/08\/table.png 987w, https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2021\/08\/table-300x134.png 300w, https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2021\/08\/table-768x343.png 768w\" sizes=\"auto, (max-width: 987px) 100vw, 987px\" \/><\/figure>\n\n\n\n<p>artist: \u30d1\u30fc\u30c6\u30b7\u30e7\u30f3\u30ad\u30fc<br>title: \u30bd\u30fc\u30c8\u30ad\u30fc<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30b9\u30ad\u30e3\u30f3\u306e\u5b9f\u884c<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u884c<\/h2>\n\n\n\n<p>artist\u540d\u304c &#8220;B&#8221; \u304b\u3089\u59cb\u307e\u308a\u3001\u304b\u3064\u3001title \u304c &#8220;IN&#8221; \u304b\u3089\u59cb\u307e\u308b\u9805\u76ee\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Lambda\u95a2\u6570\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const DynamoDbSetter = require(&quot;.\/DynamoDbSetter&quot;);\n \nmodule.exports = class DynamoDbOperator extends DynamoDbSetter{\n \n    async exec(event) {\n \n        \/\/ \u5b9f\u884c\u5185\u5bb9\n        let params = {\n            TableName : &quot;Musics&quot;,\n            FilterExpression: &quot;begins_with(#artist, :artistValue) AND begins_with(#title, :titleValue)&quot;,\n            ExpressionAttributeNames: {\n                &quot;#artist&quot;: &quot;artist&quot;,\n                &quot;#title&quot;: &quot;title&quot;,\n            },\n            ExpressionAttributeValues: {\n                &quot;:artistValue&quot;: {&quot;S&quot;: &quot;B&quot;},\n                &quot;:titleValue&quot;: {&quot;S&quot;: &quot;IN&quot;},\n            },\n            ReturnConsumedCapacity: &quot;INDEXES&quot;\n        };\n    \n        \/\/ \u5b9f\u884c\n        return await this.dynamodb.scan(params).promise();\n \n    }\n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u884c\u5185\u5bb9\u306e\u8aac\u660e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">FilterExpression<\/h3>\n\n\n\n<p>\u9805\u76ee\u3092\u53d6\u5f97\u3059\u308b\u6761\u4ef6\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br>begins_with \u306b\u3088\u308a\u524d\u65b9\u4e00\u81f4\u691c\u7d22\u304c\u53ef\u80fd\u3067\u3059\u3002<br>AND \u3084 OR \u306b\u3088\u308a\u6761\u4ef6\u3092\u8907\u6570\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d50\u679c<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;Items&quot;: [\n        {\n            &quot;year&quot;: {\n                &quot;N&quot;: &quot;1991&quot;\n            },\n            &quot;artist&quot;: {\n                &quot;S&quot;: &quot;B&#39;z&quot;\n            },\n            &quot;genre&quot;: {\n                &quot;S&quot;: &quot;Lock&quot;\n            },\n            &quot;title&quot;: {\n                &quot;S&quot;: &quot;IN THE LIFE&quot;\n            }\n        }\n    ],\n    &quot;Count&quot;: 1,\n    &quot;ScannedCount&quot;: 5,\n    &quot;ConsumedCapacity&quot;: {\n        &quot;TableName&quot;: &quot;Musics&quot;,\n        &quot;CapacityUnits&quot;: 0.5,\n        &quot;Table&quot;: {\n            &quot;CapacityUnits&quot;: 0.5\n        }\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>ScannedCount \u304c 5 \u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u30015\u9805\u76ee\u304c\u53d6\u5f97\u3055\u308c\u305f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002Count \u304c1\u306a\u306e\u3067\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u9805\u76ee\u304c1\u3064\u3042\u3063\u305f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30ad\u30e3\u30d1\u30b7\u30c6\u30a3\u30fc\u30e6\u30cb\u30c3\u30c8<\/h1>\n\n\n\n<p>\u30b9\u30ad\u30e3\u30f3\u306f\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5168\u3066\u306e\u9805\u76ee\u3092\u53d6\u5f97\u3057\u305f\u5f8c\u306b\u3001\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u9805\u76ee\u306e\u307f\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<br>\u6d88\u8cbb\u3055\u308c\u308b\u30ad\u30e3\u30d1\u30b7\u30c6\u30a3\u30fc\u30e6\u30cb\u30c3\u30c8\u306e\u8a08\u7b97\u306f\u3001\u6761\u4ef6\u306b\u4e00\u81f4\u3057\u305f\u9805\u76ee\u3067\u306f\u306a\u304f\u3001\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u53d6\u5f97\u3057\u305f\u5168\u3066\u306e\u9805\u76ee\u306e\u30b5\u30a4\u30ba\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<br>\u30b9\u30ad\u30e3\u30f3\u306f\u3042\u304f\u307e\u3067\u3082\u30c6\u30fc\u30d6\u30eb\u306e\u9805\u76ee\u5168\u3066\u3092\u53d6\u5f97\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h1>\n\n\n\n<p>\u6b21\u56de\u306fDynamoDB\u304c\u9805\u76ee\u306e\u6709\u52b9\u671f\u9650\u3092\u5224\u65ad\u3057\u3066\u81ea\u52d5\u7684\u306b\u9805\u76ee\u3092\u524a\u9664\u3059\u308b\u4e8b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u6b21\u56de<\/span>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=1982\" rel=\"noopener\" target=\"_blank\">\u3010DynamoDB\u3011AWS SDK \u3092\u4f7f\u7528\u3057\u305f\u9805\u76ee\u306e\u6709\u52b9\u671f\u9650\u306e\u8a2d\u5b9a<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u8907\u6570\u9805\u76ee\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3001query\u3092\u4f7f\u3046\u65b9\u6cd5\u4ee5\u5916\u306bscan\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":7,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,19,20],"tags":[],"class_list":["post-2128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-dynamodb","category-lambda"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/2128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2128"}],"version-history":[{"count":11,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/2128\/revisions"}],"predecessor-version":[{"id":3389,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/2128\/revisions\/3389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/7"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}