小编Yas*_*aka的帖子

DynamoDB将新地图添加到列表

我正在尝试将新的Map添加到DynamoDB中的列表(注释)中,但似乎无法正确完成。下面是该表的简单结构:

{
  "Comments": [
    {
      "Body": "This is the first comment",
      "Username": "admin"
    },
    {
      "Body": "This is the second comment",
      "Username": "Jenny"
    },
    {
      "Body": "This is the third comment",
      "Username": "Bob"
    }
  ],
  "PostId": "RY28q1AxhR9Qi2VjrDdUdo5bPXBybUg2"
}
Run Code Online (Sandbox Code Playgroud)

PHP代码:

$response = $ddb->updateItem (
              [
                'TableName'     => 'comments',
                  'Key'         => [
                    'PostId'    => ['S' => $request->input('postid')]
                  ],
              "ExpressionAttributeNames" => ["#theList" => "Comments"],
              "ExpressionAttributeValues" => [
                  ':addVal' => [
                      'M' =>  [
                        'Username' => ['S' => 'MrSmith'],
                        'Body' => ['S' => 'Hello …
Run Code Online (Sandbox Code Playgroud)

php amazon-dynamodb aws-sdk

8
推荐指数
2
解决办法
2696
查看次数

标签 统计

amazon-dynamodb ×1

aws-sdk ×1

php ×1