我正在尝试将新的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)