title: How to add JS object into Sqlite database
body: <p>I am having trouble trying to add a JS Object into an sqlite database. I am using cordova, creating an app for android, windows and iOS. </p>
  
  <p>I have this code for my insert and retrieval...</p>
  
  <pre><code>var data = localStorage.getItem('folderData');
  console.log(data);
  var username = localStorage.getItem("username");
  var session = localStorage.getItem("session_ID");
  tx.executeSql('CREATE TABLE IF NOT EXISTS folderData (id integer primary key autoincrement, username, sessionID, folderData text)');
  tx.executeSql('SELECT * FROM folderData WHERE username = "'+username+'"', [], function(tx, result) {
      if(result.rows.length &gt; 0){
          tx.executeSql('UPDATE folderData SET folderData = "'+data+'", sessionID = "'+session+'" WHERE username = "'+username+'"');
          alert('An update has occured folderData');
      } else {
          tx.executeSql('INSERT INTO folderData (username, sessionID, folderData) VALUES ("'+username+'", "'+session+'", "'+data+'")');
          alert('An insert has occured folderData');
      }
  });
  tx.executeSql('SELECT folderData FROM folderData WHERE username = "'+username+'" AND sessionID = "'+session+'" ORDER BY id desc LIMIT 1', [], function(tx, result) {
      querySuccessFolderData(tx, result);
  });
  </code></pre>
  
  <p>The data variable is my object. When I console.log(data) before insertion i get the following</p>
  
  <p><img src="https://i.stack.imgur.com/rRI6T.png" alt="enter image description here"></p>
  
  <p>This my <code>querySuccessFolderData</code> function</p>
  
  <pre><code>function querySuccessFolderData(tx, results) {
      var len = results.rows.length;
      //alert("folderData table: " + len + " rows found.");
      var newFolderData = jsonParse(results.rows.item(0).folderData);
      for(i=0;i&lt;len;i++)
      {
          var newFolderData = results.rows.item(i).folderData;
      }
      console.log(newFolderData);
  }
  </code></pre>
  
  <p><code>console.log(newFolderData);</code> now shows up as <code>[Object Object]</code></p>
  
  <p>What am I doing wrong? Do i need to convert the object again after I select it from the database? This is becoming a nightmare for me now, i've been looking at it for way too long. Any help would be much appreciated.</p>