Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
NUMBER_VALUE no se puede convertir en cadena al actualizar el elemento

Tengo este extraño problema con DynamoDB en el que parece que no puedo actualizar un elemento.

Aquí está mi comando:

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

He verificado que la tabla es correcta y que la clave del UID de la tabla sí tiene el hash h4XJj3YRxZiF7TDcGkxAhc como valor. numRatings actualmente es igual a 1.

Aquí está mi código:

 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)); ...

Sin embargo, recibo este error: NUMBER_VALUE cannot be converted to String , tal vez estoy ciego, pero no puedo ver dónde podría estar ocurriendo esta conversión.

Estoy usando TypeScript y AWS-SDK 3.54.0

Si alguien es capaz de señalar lo que estoy haciendo mal se lo agradecería mucho.

Artículo

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Según la documentación de AttributeValue :

Los números se envían a través de la red a DynamoDB como cadenas, para maximizar la compatibilidad entre idiomas y bibliotecas. Sin embargo, DynamoDB los trata como atributos de tipo numérico para operaciones matemáticas.

Entonces necesita enviar valores numéricos como tipo N pero el valor es una cadena:

 ':numRatings': { N: `${numRatings}` }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!