SQLLite SELECT result to objects


#1

This is my method that gets the data from a SQLLIte table.

export function getProfileRecord() {

  db.transaction(
    tx => {

      tx.executeSql('select * from profile', [], (_, { rows }) =>
        {
          //console.log(rows);
          //console.log(rows);

          console.log(rows);
        }
      );
    },
    null,
    null
  );


  }

This returns something like below

WebSQLRows {
"_array": Array [
Object {
“bmi”: 24.7,
“id”: 1,
“imperialgoalweight”: 154.3,
“imperialheight”: 70.9,
“imperialweight”: 176.4,
“metricgoalweight”: 70,
“metricheight”: 180,
“metricweight”: 80,
“standard”: “Metric”,
},
Object {
“bmi”: 24.7,
“id”: 2,
“imperialgoalweight”: 154.3,
“imperialheight”: 70.9,
“imperialweight”: 176.4,
“metricgoalweight”: 70,
“metricheight”: 180,
“metricweight”: 80,
“standard”: “Metric”,
},
Object {
“bmi”: 26.2,
“id”: 3,
“imperialgoalweight”: 154.3,
“imperialheight”: 70.9,
“imperialweight”: 187.4,
“metricgoalweight”: 70,
“metricheight”: 180,
“metricweight”: 85,
“standard”: “Metric”,
},
],
“length”: 3,
}

Is there any way I can convert the result set into objects ?


#2

You have the result rows, so how you decide to manipulate the data is up to you.