满足特定条件时增加 dynamoDB 表中属性的值

问题描述

我正在使用 DynamoDBMapper 根据某些属性值保存对 dynamoDB 数据库的更改。如果关注者数量低于特定值,我想为每次调用 API 增加艺术家 xyz 的关注者数量。我的 dynamoDB 表中有 artistfollowers 属性。如果我事先知道 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...