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

265
Visualizações
Nodejs push data and get JSON from mysql

I have a search query running on nodejs modal as I put below. I am getting users from this query to my app as JSON data like this.

{id, username, name, sirname, birthdate, weight, height, photo}

{id, username, name, sirname, birthdate, weight, height, photo}

But I need to get users talents from an other table . So my JSON data must be like this.

{
id: 1 {talentone : 'good', talenttwo : 'bad', talentthree : 'good'}, 
username, name, sirname, birthdate, weight, height, photo}
{
id:2 {talentone : 'good', talenttwo : 'bad', talentthree : 'good'}, 
username, name, sirname, birthdate, weight, height, photo}
id:3 {talentone : 'good', talenttwo : 'bad', talentthree : 'good'}, 
username, name, sirname, birthdate, weight, height, photo}

My talents table: id - userId, talentName, talentRate

My user search query and nodejs code :

Searchtalent.getAll =(searchtalent, result) => {
  sql.query(`SELECT id, username, name, sirname, birthdate, weight, height, photo FROM users WHERE 
  user_type = 'sportsman'
  AND (birthdate BETWEEN '${searchtalent.birthdatefirst}' AND '${searchtalent.birthdatelast}')
  AND (weight BETWEEN ${searchtalent.wfirst} AND ${searchtalent.wsecond})
  AND (height BETWEEN ${searchtalent.hfirst} AND ${searchtalent.hsecond})
  AND lang LIKE '%${searchtalent.lang}%' 
  AND gender LIKE '%${searchtalent.gender}%' 
  AND username LIKE '%${searchtalent.username}%' 
  AND name LIKE '%${searchtalent.name}%' 
  AND sirname LIKE '%${searchtalent.sirname}%' 
  AND branch LIKE '%${searchtalent.branch}%' 
  AND branch_status LIKE '%${searchtalent.branch_status}%' 
  AND city LIKE '%${searchtalent.city}%' 
  AND foot LIKE '%${searchtalent.foot}%' 
  AND hand LIKE '%${searchtalent.hand}%' 
  AND first_position LIKE '%${searchtalent.first_position}%' 
  AND second_position LIKE '%${searchtalent.second_position}%' 
  AND nationality LIKE '%${searchtalent.nationality}%' 

LIMIT 50` ,(err, res) => {
    if (err) {
      console.log("error: ", err);
      result(err, null);
      return;
    }

    if (res.length) {
      console.log("found users: ", searchtalent);
      result(null, res);
      return;
    }

    // not found users with the id
    result({ kind: "not_found" }, null);
  });
};
about 4 years ago · Juan Pablo Isaza
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