- 
                Notifications
    You must be signed in to change notification settings 
- Fork 689
Api
        Mathias Rangel Wulff edited this page Jun 13, 2015 
        ·
        8 revisions
      
    - alasql(stringWithSQL)
- alasql.compile(stringWithSQL) - Pre compile statements
Please see more info about the alasql object here
    alasql(‘CREATE DATABASE test01’);
    alasql(‘USE test01’);
    alasql(‘CREATE TABLE one (a INT)’);
    alasql(‘INSERT INTO one VALUES (10)’):
    var res = alasql(‘SELECT * FROM one’);    var data = [{a:1}, {a:2}, {a:3}];
    alasql(‘SELECT * FROM ? WHERE a >= ?’, [data, 2]);
    // or
    var db = new alasql.Database();
    db.exec(“select * from one”, function(data) {
        console.log(data.length);
    });AlaSQL supports promises with alasql.promise(sql,params) function. It returns a standard A/+ promise:
    alasql.promise('SELECT * FROM test')
    }).then(function(res){
        // Process data
    }).catch(function(err){
        // Process errors
    });    var db = new alasql.Database(‘mydb’);
    db.exec(‘SELECT * FROM City”);    alasql.fn.Date = Date;
    alasql('CREATE order (orderno INT, orderdate Date)');NB. Classes are case-sensitive
Register class as alasql type
    alasql.fn.Date = Date;Use NEW
    alasql(‘SELECT NEW Date(yr,mn-1,dy) FROM orderdates’)Please See [JSON Objects](Json Objects)
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo