AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
I am finding that adding a column isn't including the data type. I've attached a screenshot of the Chrome localStorage viewer as well as the code I use.
localStorage.clear();
alasql('CREATE localStorage DATABASE IF NOT EXISTS register');
alasql('ATTACH localStorage DATABASE register AS myregister');
alasql('USE myregister;');
alasql("CREATE TABLE IF NOT EXISTS transactions(transid STRING, payee STRING, amount DECIMAL)");
for(var x=0; x<=3; x++){
alasql("INSERT INTO transactions VALUES (?,?,?)", ["a","b","c"]);
}
alasql("ALTER TABLE transactions ADD COLUMN notes STRING;");
alasql("INSERT INTO transactions VALUES (?,?,?,?)", ["a","b","c","some notes"]);
var res = alasql('SHOW COLUMNS FROM transactions;');
alert(JSON.stringify(res));
var res = alasql("SELECT * FROM transactions");
alert(res[4].notes);
localStorage.clear();
This code alerts to the browser the structure of transactions table after the notes column is added, and it also alerts to show that the value is added when I insert data.
Here is the picture