问题描述
我正在使用 DynamoDBMapper 根据某些属性值保存对 dynamoDB 数据库的更改。如果关注者数量低于特定值,我想为每次调用 API 增加艺术家 xyz
的关注者数量。我的 dynamoDB 表中有 artist
和 followers
属性。如果我事先知道 followers
的值,我就可以更新表。但是,我想从表中读取 followers
的数据,并且仅当条件表达式的计算结果为 true 时才将属性增加 1。这可以通过 DynamoDBMapper 实现吗?如果没有,可以采取哪些其他方法来实现这一目标?到目前为止,这是我的代码在条件更新时的样子:
val expr = DynamoDBSaveExpression()
val expAttr = ImmutableMap.builder<String,ExpectedAttributeValue>()
.put("artist". ExpectedAttributeValue.withValue("xyz"))
.put("followers". ExpectedAttributeValue.withValue("1000").withComparisonoperator(Comparisonoperator.LE))
.build()
expr.expected = expAttr
expr.setConditionalOperator(ConditionalOperator.AND)
myMapper.save(allData,expr) // myMapper is an instance of DynamoDBMapper
// allData is an object that maps to dynamoDB table where artist is the partition key of the table
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)