zoukankan      html  css  js  c++  java
  • [AWS DA] DynamoDB CLI

    Using --project-expression:

    aws dynamodb scan --table-name users --projection-expression "user_id,game_id"
    {
        "Items": [
            {
                "user_id": {
                    "S": "ersaessew"
                },
                "game_id": {
                    "N": "123"
                }
            },
            {
                "user_id": {
                    "S": "fgxfbgf"
                },
                "game_id": {
                    "N": "234"
                }
            }
        ],
        "Count": 2,
        "ScannedCount": 2,
        "ConsumedCapacity": null
    }

    Using --filter-expression:

    aws dynamodb scan --table-name users --filter-expression "user_id= :u" --expression-attribute-values '{ ":u": {"S": "ersaessew"}}'

    result:

    {
        "Items": [
            {
                "user_id": {
                    "S": "ersaessew"
                },
                "game_id": {
                    "N": "123"
                },
                "game_ts": {
                    "S": "2021-05-31T11:34:19.266Z"
                }
            }
        ],
        "Count": 1,
        "ScannedCount": 2,
        "ConsumedCapacity": null
    }

    Using --page-size: 

    total we have 2 items, set page size = 1, it performance 2 api calls.

    aws dynamodb scan --table-name users --page-size 1

    Result:

    {
        "Items": [
            {
                "user_id": {
                    "S": "ersaessew"
                },
                "game_id": {
                    "N": "123"
                },
                "game_ts": {
                    "S": "2021-05-31T11:34:19.266Z"
                }
            },
            {
                "user_id": {
                    "S": "fgxfbgf"
                },
                "game_id": {
                    "N": "234"
                },
                "game_ts": {
                    "S": "2021-05-30T11:34:19.266Z"
                }
            }
        ],
        "Count": 2,
        "ScannedCount": 2,
        "ConsumedCapacity": null
    }

    If we want to limit api calls when using page size, we can use: --max-items:

    --page-size and --max-items doesn't need to be used at the same time.

    --max-items is for limit RCU

    --page-size is avoid timeout

    aws dynamodb scan --table-name users --page-size 1 --max-items 1
    {
        "Items": [
            {
                "user_id": {
                    "S": "ersaessew"
                },
                "game_id": {
                    "N": "123"
                },
                "game_ts": {
                    "S": "2021-05-31T11:34:19.266Z"
                }
            }
        ],
        "Count": 1,
        "ScannedCount": 1,
        "ConsumedCapacity": null,
        "NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IHsidXNlcl9pZCI6IHsiUyI6ICJlcnNhZXNzZXcifSwgImdhbWVfdHMiOiB7IlMiOiAiMjAyMS0wNS0zMVQxMTozNDoxOS4yNjZaIn19fQ=="
    }

    "NextToekn" is what you should use to get next batch of items.

    aws dynamodb scan --table-name users --page-size 1 --max-items 1 --starting-token eyJFeGNsdXNpdmVTdGFydEtleSI6IHsidXNlcl9pZCI6IHsiUyI6ICJlcnNhZXNzZXcifSwgImdhbWVfdHMiOiB7IlMiOiAiMjAyMS0wNS0zMVQxMTozNDoxOS4yNjZaIn19fQ==
    {
        "Items": [
            {
                "user_id": {
                    "S": "fgxfbgf"
                },
                "game_id": {
                    "N": "234"
                },
                "game_ts": {
                    "S": "2021-05-30T11:34:19.266Z"
                }
            }
        ],
        "Count": 0,
        "ScannedCount": 0,
        "ConsumedCapacity": null,
        "NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IHsidXNlcl9pZCI6IHsiUyI6ICJmZ3hmYmdmIn0sICJnYW1lX3RzIjogeyJTIjogIjIwMjEtMDUtMzBUMTE6MzQ6MTkuMjY2WiJ9fX0="
    }

    If there is no items anymore:

    {
        "Items": [],
        "Count": 0,
        "ScannedCount": 0,
        "ConsumedCapacity": null
    }
  • 相关阅读:
    关于分工协作
    SQL分类后每类随机抽取
    新浪微群抢票
    to learn softwarelist
    大厂程序员教你如何学习C++(内附学习资料)
    干货|大厂程序员来讲一下互联网公司技术面试的流程以及注意事项
    程序员要如何写简历(附简历模板)
    laravel项目拉取下来安装,node.js库安装
    laravelhas方法查看关联关系
    laravel框架少见方法详解
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14832942.html
Copyright © 2011-2022 走看看