简体   繁体   中英

How to update a value for reserved keyword in Dynamo DB. Error: Attribute name is a reserved keyword; reserved keyword: data

This is the update query I am operating. Error is here "set data =:updateValue", data is a reserved keyword from Dynamo DB. I think I should use update ExpressionAttributes here but not sure how to use for this case.

UpdateItemSpec updatetable = new UpdateItemSpec()
                .withPrimaryKey("pId", jsonContext.read("$.pId"))
                .withUpdateExpression("set data = :updateValue")
                .withValueMap(new ValueMap().with(":updateValue", jsonpathCreatorLocation2));
    locTable2.updateItem(updatetable);
final Map<String, String> expressions = new HashMap<>();
expressions.put("#d", "data");

UpdateItemSpec updatetable = new UpdateItemSpec()
                .withPrimaryKey("pId", jsonContext.read("$.pId"))
                .withUpdateExpression("set #d = :updateValue")
                .withValueMap(new ValueMap().with(":updateValue", jsonpathCreatorLocation2));
                .withExpressionAttributeNames(expressions);

locTable2.updateItem(updatetable);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM