I have a record in DynamoDB with an field named imageData, this field is a list of items, each item is a dictionary (map containing key value pairs)
How can I append new items to the list in the following record
{ "ssid": "abcd", "imageData": []}
I tried
Table table = dynamoDB.getTable("my_table");
HashMap imageData = new HashMap();
imageData.put("imageKey", "xyz.jpg" );
imageData.put("imageUploadTimestamp", "2016-12-12 23:59:59");
ValueMap map = new ValueMap().withList(":img", Arrays.asList(imageData));
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey(SSID, ssid)
.withUpdateExpression("set imageData = list_append(imageData, :img )")
.withValueMap(map);
UpdateItemOutcome result = table.updateItem(updateItemSpec);
Is this the right way? is there a better way?
这是在DynamoDB中追加到列表属性的好方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.