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

143
Views
Loopback4 ejecuta sql con params / ER_BAD_FIELD_ERROR: columna desconocida 'reactionType' en 'field list'

Quiero aumentar el valor de la columna 'reactionType' en mi tabla en 1 de acuerdo con el valor 'reactionType' que obtengo de la API. El tipo de reacción es un punto final variable. por ejemplo, /me gusta /no me gusta ... Si se recibe un me gusta, aumentaré el valor de la columna me gusta. Si no me gusta, aumentaré el valor de la columna de no me gusta.

 @patch('/news-reaction/{id}/{reactionType}') @response(204, { description: 'updateReaction PATCH success', }) async updateReaction( @param.path.number('id') id: typeof News.prototype.id, @param.path.string('reactionType') reactionType: string, ): Promise<void> { await this.newsReactionRepository.execute('UPDATE `news_reaction` SET `${reactionType}` = `${reactionType}` +1 WHERE `newsId`=?', [id,reactionType]); } }

Estoy recibiendo un error. ¿Cómo debería ser?

error: la solicitud PATCH /news-reaction/431224/sad falló con el código de estado 500. Error: ER_BAD_FIELD_ERROR: Columna desconocida '${reactionType}' en 'lista de campos'

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

0

Creo que hay dos problemas en tu código:

  1. ${} los reemplazos no funcionan aquí
  2. los reemplazos de parámetros son 1 a 1 con ? en orden aparecen

No pude probarlo, pero espero que funcione.

 await this.newsReactionRepository.execute( 'UPDATE `news_reaction` SET `?` = `?` + 1 WHERE `newsId` = ?', [reactionType,reactionType,id] );
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!