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

266
Views
Nodejs inserta datos y obtiene JSON de mysql

Tengo una consulta de búsqueda ejecutándose en nodejs modal como pongo a continuación. Obtengo usuarios de esta consulta a mi aplicación como datos JSON como este.

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

Pero necesito obtener los talentos de los usuarios de otra mesa. Entonces mis datos JSON deben ser así.

 { 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}

Mi tabla de talentos: id - userId, talentName, talentRate

Mi consulta de búsqueda de usuario y código nodejs:

 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
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!