java - list_append causing duplicates in Map. if list_append called for for existing keys in DynamoDB -
in following code in java trying append item "test.com" map field named "daily". when run code adds dulplicate key map.
map<string,string> atrval = new hashmap<string,string>(); atrval.put("test.com", json); updateitemspec updateitemspec = new updateitemspec() .withprimarykey("id", id) .withupdateexpression("set daily = list_append(daily , :r)") .withconditionexpression("attribute_not_exists (daily.#k1)") .withvaluemap(new valuemap() .withlist(":r", arrays.aslist(atrval)) ) .withnamemap(new namemap() .with("#k1", "test.com")); table.updateitem(updateitemspec);
attribute_not_exists
should preventing doing that. ideas why not working.
as have map
inside list
, api expects index of list (something below). in java terms, data type of daily list<map<string, string>>
.
when "daily.stringvalue" (i.e. daily."test.com"), can't find string value there object (i.e. map) present inside list rather string value.
"attribute_not_exists (daily[0].#k1)"
when index given, searches key inside first element.
if list have been list<string>
, there option use contains
. however, can't used due complexity of model.
contains supported lists: when evaluating "a contains b", "a" can list; however, "b" cannot set, map, or list.
Comments
Post a Comment