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

52
Vistas
store data table to object

I have web app that I need store store data table to object I have JavaScript code below that connect first to the database and SELECT table

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

  var config = {
  user: '****',
  password: '*****',
  server: '****',
  databse:'****',
  options: {
      trustedConnection: true,
      trustServerCertificate: true
    },
  };
  
  sql.connect(config, function (err) {
      if (err) console.log(err);
      // create Request object
      var request = new sql.Request();
      // query to the database and get the records
      request.query("select * from Test ", function (err, recordset) {
  
          if (err) console.log(err)
          // write the records in console.log
          console.log(recordset) 
   
      });
  });
      

below is the terminal output.

 recordset: [
    { ID: '1111      ', Name: 'Fahad     ', Age: '30        ' },
    { ID: '2222      ', Name: 'Omar      ', Age: '20        ' }
  ],

So I need to store the recordset to

var users = [{}]

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

users = [
    { ID: '1111', Name: 'Fahad', Age: '30' },
    { ID: '2222', Name: 'Omar', Age: '20' }
  ]
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

hope this example will help you

you can simply use localStorage API for this, first you need to stringify the data which is in the type array then you can store the data then next time when the user accessing the page you can convert the data to array with the help of JSON.parse()

let data_to_store = [{user : "blob"}]

if(!localStorage.dataTableStored){
  localStorage.dataTableStored = JSON.stringify(data_to_store);
}
else{
    console.log("this data is stored in     localstorage",JSON.parse(localStorage.dataTableStored))
}

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