Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
sql table's data to array javascript

I have JavaScript code below that connect to the database and SELECT table

//Connect to database
  var sql = require("mssql");

  var config = {
  user: '****',
  password: '*****',
  server: '****',
  databse:'****',
  };
  
  sql.connect(config)
      var request = new sql.Request();
      // query to the database and get the records
      request.query("select * from Test ")

below is the terminal output.

 recordset: [
    { ID: '0      ', Name: 'Test1     ', Age: '80        ' },
    { ID: '1      ', Name: 'Test2      ', Age: '55        ' }
  ],

So I need to make array below take all data from recordset, so I can use the array in other functions

var users = [{}]

when open the page on the browser the var users should look

users = [
    { ID: '0', Name: 'Test1', Age: '80' },
    { ID: '1', Name: 'Test2', Age: '55' }
  ]
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you already have recordset in desired format and you want it to be users, you can do this:

var users = recordset; 

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda