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

151
Views
Estoy usando una matriz para actualizar la base de datos MYSQL pero la ID no coincide

Estoy recorriendo una matriz en el nodo JS para actualizar la base de datos MYSQL, pero la matriz comienza en 0 y mi base de datos de incremento automático comienza en 1. Esto obviamente compensa toda mi base de datos en 1 fila. Agradecería mucho una solución a esto. También estoy usando el paquete Sequelize NPM. Gracias por adelantado.

 function ejsoutput(json){ for(var i = 0; i < 10;i++){ const updatedRank = json.entries[i].rank; const updatedRating = json.entries[i].rating; const updatedName = json.entries[i].character.name; const updatedRealm = json.entries[i].character.realm.slug; const updatedFaction = json.entries[i].faction.type; const updatedPlayed = json.entries[i].season_match_statistics.played; const updatedWon = json.entries[i].season_match_statistics.won; const updatedLost = json.entries[i].season_match_statistics.lost; Product.findByPk(i) .then(product => { product.rank = updatedRank; product.rating = updatedRating; product.name = updatedName; product.realm = updatedRealm; product.faction = updatedFaction; product.played = updatedPlayed; product.won = updatedWon; product.lost = updatedLost; return product.save(); }) .then(result => { console.log('UPDATED PRODUCT') }) .catch(err => console.log(err));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Acabo de agregar esto al código.

 Product.findByPk(i + 1)
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!