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

157
Views
¿Qué es un conjunto análogo de squel.js en knex.js?

¿Cómo puedo reescribirlo usando Knex.js?

 type === 'insert' ? sql = squel.insert() .set('id', userId) .set('type', 'open') .set('server', server) .set('created_at', timestamp) .set('updated_at', timestamp) .into('saved_users') : sql = squel.update() .table('saved_users') .set('updated_at', timestamp) .where(`id = "${userId}"`) for (const param in player) { if (param === 'full_response') continue; const value = player[param]; if (param === 'kill') { sql.set(`\`${param}\``, value ?? 0) } else { sql.set(param, value ?? 0) } }

Estoy usando .set(..) para agregar la consulta de inserción o actualización. ¿Cómo hacerlo usando Knex?

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

0

Algo así =/ Tal vez pueda mejorar

 const data = {} const query = knex("saved_users") for (const param in player) { if (param === 'full_response') continue; const value = player[param]; if (param === 'kill') { data[param] = value ?? 0 } else { data[param] = value ?? 0 } } if (type === "insert") { data["id"] = userId; data["type"] = "open"; data["server"] = server; data["created_at"] = timestamp; data["updated_at"] = timestamp; await query.insert(data) } else { data["updated_at"] = timestamp await query.update(data).where({ id: userId }) }
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!