从 DynamoDb 中删除列表项
Removing a List Item from DynamoDb
需要使用其索引从 React 应用程序中的 DynamoDb 数据库中删除列表项。
按照中的示例
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Js.03.html ,
更新项目(有条件地)
删除项目的更新表达式是
UpdateExpression: "remove info.actors[0]",
当索引值作为函数的参数时更新表达式是什么?
执行此操作的唯一方法是只构建 UpdateExpression
字符串,其中包含适当的数字。正如 LazyElephant 在评论中建议的那样:"Remove info.actors[" + index + "]"
.
您可能认为 remove info.actors[:i]
也应该可以写成 remove info.actors[:i]
,其中 :i
定义在 ExpressionAttributeValues
中。但不幸的是,这不起作用。 DynamoDB 将其作为语法错误拒绝。我不能说我明白为什么。
需要使用其索引从 React 应用程序中的 DynamoDb 数据库中删除列表项。
按照中的示例 https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Js.03.html , 更新项目(有条件地)
删除项目的更新表达式是
UpdateExpression: "remove info.actors[0]",
当索引值作为函数的参数时更新表达式是什么?
执行此操作的唯一方法是只构建 UpdateExpression
字符串,其中包含适当的数字。正如 LazyElephant 在评论中建议的那样:"Remove info.actors[" + index + "]"
.
您可能认为 remove info.actors[:i]
也应该可以写成 remove info.actors[:i]
,其中 :i
定义在 ExpressionAttributeValues
中。但不幸的是,这不起作用。 DynamoDB 将其作为语法错误拒绝。我不能说我明白为什么。