NOTE:可能看起来像this的复制品,但它不同,因为我需要通过Golang来完成,而那是在JS中.
我想在goSDK中对DynamoDB项执行以下操作:
UpdateExpression: 'ADD socialAccounts :socialAccountId',
ExpressionAttributeValues: {
':socialAccountId': {
'SS': [socialAccountId]
}
},
在GoSDK中,这通常是这样的:
expression.Add(expression.Name("socialAccounts"), expression.Value([]string{"socialAccountId"}))
然而,SDK没有将字符串数组作为SS
(StringSet)类型,而是将其作为L
(List)类型.
记录的错误:
Error: ValidationException: Invalid UpdateExpression: Incorrect operand type for operator or function; operator: ADD, operand type: LIST, typeSet: ALLOWED_FOR_ADD_OPERAND
我找不到任何指定如何提及类型的功能in the docs.
Can anyone help?
Why I want to do it this way:
- 我希望即使在属性
socialAccounts
不存在的情况下,这也能起作用. - 我不想对
list_append
使用SET
操作,因为那样会引入重复的元素.