baopham / laravel-dynamodb

Eloquent syntax for DynamoDB
https://packagist.org/packages/baopham/dynamodb
MIT License
490 stars 127 forks source link

set atomic counter with eloquent or raw query ? #284

Closed persarifin closed 3 months ago

persarifin commented 4 months ago

sorry for my english

I try to update dataSET myNumber = myNumber + :increment in raw query like this

DynamoDb::table(myTable) ->setKey(DynamoDb::marshalItem(['id' => myId])) ->setUpdateExpression('SET #myNumber = #myNumber + :increment') ->setExpressionAttributeName('#myNumber', 'myNumber') ->setExpressionAttributeValue(':increment', DynamoDb::marshalValue(1)) ->prepare() ->updateItem()

and I got this issue

Error executing "UpdateItem" on "https://dynamodb.ap-southeast-1.amazonaws.com"; AWS HTTP error: Client error: POST https://dynamodb.ap-southeast-1.amazonaws.com resulted in a 400 Bad Request response:{"type":"com.amazon.coral.validate#ValidationException","message":"An operand in the update expression has an incorrec (truncated...)ValidationException (client): An operand in the update expression has an incorrect data type - {"type":"com.amazon.coral.validate#ValidationException","message":"An operand in the update expression has an incorrect data type"}

 


can anyone help, how do I update the data to add new values? or tell me how to create direct query to dynamo with this library?