minidyn
minidyn copied to clipboard
[ConditionExpression] attribute_type not working
Hello
I want to insert item_a
{
"AccountId": {
"S": "123"
}
}
with a conditional expression like this:
input := &dynamodb.PutItemInput{
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":v_sub": {
S: aws.String("S"),
},
},
ConditionExpression: aws.String("attribute_type(AccountId, :v_sub)"),
Item: av,
TableName: &p.tableName,
}
av is the marshalled item_a
but unfortunately i get this error:
ConditionalCheckFailedException: conditional request failed
According to the readme, attribute_type is supported.
i used these two docs as a reference: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html
kind regards erik
Opps, sorry for the late response: the ConditionExpressions evaluates the already stored item, because the are used to avoid overrides in the PutItem operations.