UNPKG

kloudglue-alasql

Version:

Versatile SQL database for browser or node. Handles relational data and nested JSON (noSQL). Export to and import from Excel, localStorage or IndexedDB

24 lines (20 loc) 765 B
<p>Big cities:<span id="res"></span></p> <script src="../../alasql.js"></script> <script> var cityData = [{city:"Redmond", population:57530}, {city:"Atlanta",population:447841}, {city:"San Fracisco", population:837442}]; // Create IndexdDB database and fill it with data from array alasql('CREATE INDEXEDDB DATABASE IF NOT EXISTS geo;\ ATTACH INDEXEDDB DATABASE geo; \ USE geo; \ DROP TABLE IF EXISTS cities; \ CREATE TABLE cities; \ SELECT * INTO cities FROM ?', [cityData], function(){ // Select data from IndexedDB alasql('SELECT COLUMN * FROM cities WHERE population > 100000 ORDER BY city DESC', [],function(res){ document.getElementById('res').textContent = res.join(', '); }); }); </script>