JSFiddle - React, Tailwind, and code Playground

by rgthree

JavaScript

var node = {};
var getNode = function(callback){
    var database = openDatabase('db', "1", "object store", 10);
    database.transaction(function(tx) {
     tx.executeSql("CREATE TABLE IF NOT EXISTS name (NodeId int, NodeName text)", [], function(tx) {
      tx.executeSql("insert into name (NodeId,NodeName) values (1,'node')",[],function(tx){
       tx.executeSql("select * from name where NodeId=1",[],function(tx,res){
         // Parse node to an unprotected JSON Object
         node = JSON.parse(JSON.stringify(res.rows.item(0)));
         // Now that we've set node, let's call the callback we passed in.
         callback && callback();
       });
      });
     }, {});
    });
};
// Call get node and pass a function that will be executed
// _after_ the data is asynchronously retrieved
getNode(function(){
  node.NodeId = 22;
  delete node.NodeId;
  console.log(node); // Now, node.NodeId has been deleted
});