Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

275
Visualizações
NUMBER_VALUE cannot be converted to String when updating Item

I have this strange issue with DynamoDB where I cannot seem to update an item.

Here is my command:

TableName: 'UserTable',
Key: { UID: { S: 'h4XJj3YRxZiF7TDcGkxAhc' } },
UpdateExpression: 'SET numRatings = :numRatings',
ExpressionAttributeValues: { ':numRatings': { N: 336 } },
ReturnValues: 'UPDATED_NEW'

I have verified that the table is correct, and that the key of the table UID does indeed have the hash h4XJj3YRxZiF7TDcGkxAhc as a value. numRatings currently is equal to 1.

Here's 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));
...

Yet I get this error: NUMBER_VALUE cannot be converted to String maybe I am blind but I cannot see where this conversion could be taking place.

I am using TypeScript and AWS-SDK 3.54.0

If anyone is able to point out what I am doing wrong I would greatly appreciate it.

Item

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Per the AttributeValue documentation:

Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

So you need to send numeric values as type N but the value is a string:

':numRatings': { N: `${numRatings}` }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda