(I'm using AWS PHP SDK)
Let's say i have a Table:
Table name: article
Primary partition key: article_id (Number)
With a sample of manually created Item:
{
"article_id": 10010,
"updated": "2018-02-22T20:15:19.28800Z",
"comments": [ "Nice article!", "Thank you!" ]
}
Adding new comment:
I know how to entirely update (overwrite) this existing Item, in this way:
$key = $marshaler->marshalJson('
{
"article_id": 10010
}
');
$eav = $marshaler->marshalJson('
{
":u": "2018-02-22T20:15:19.28800Z",
":c": [ "Nice article!", "Thank you!", "This is the new one!" ]
}
');
$params = [
'TableName' => 'article',
'Key' => $key,
'ExpressionAttributeValues'=> $eav,
'UpdateExpression' => 'set updated=:u, comments=:c',
'ReturnValues' => 'UPDATED_NEW'
];
I can somehow APPEND new values (aka) add new comment, this way. But this is literally still recreating the whole entire Item again, which is not the way i preferred.
How do i just simply APPEND new values into an List/Array inside an existing Item, please?
commentsarray.