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

51
Views
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 answers
Answer question

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