I've encountered a strange issue with DynamoDB where I'm unable to update an item.
Below is the command I'm using:
TableName: 'UserTable',
Key: { UID: { S: 'h4XJj3YRxZiF7TDcGkxAhc' } },
UpdateExpression: 'SET numRatings = :numRatings',
ExpressionAttributeValues: { ':numRatings': { N: 336 } },
ReturnValues: 'UPDATED_NEW'
I've double-checked that the table and key values are correct. The key value for UID in the table is indeed 'h4XJj3YRxZiF7TDcGkxAhc', and the current value of 'numRatings' is 1.
Here's the relevant snippet of my code:
const params = {
TableName: process.env.USER_TABLE_NAME!,
Key: {
UID: {
S: UID
}
},
UpdateExpression: 'SET numRatings = :numRatings',
ExpressionAttributeValues: {
':numRatings': { N: numRatings } as unknown as AttributeValue
},
ReturnValues: 'UPDATED_NEW'
} as UpdateItemCommandInput;
try {
const result = await dbClient.send(new UpdateItemCommand(params));
...
Despite this, I keep encountering the error:
NUMBER_VALUE cannot be converted to String
, leading me to believe there might be a conversion happening somewhere that I'm missing.
My setup involves TypeScript and AWS-SDK version 3.54.0
If anyone can spot what I'm overlooking, I'd greatly appreciate the help.