Skip to content

Commit

Permalink
version 0.0.45
Browse files Browse the repository at this point in the history
  • Loading branch information
agershun committed Apr 13, 2015
1 parent 11efcc6 commit 00cf108
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

### 0.0.45 "Rio de Janeiro" (14.04.2015 - ...04.2015)
* Added Bower package
* Changed CRLF for alacon.js and alaserver.js to LF

### 0.0.44 "Roma" (02.04.2015 - 13.04.2015)
* Added params to SQLite attached database: alasql('ATTACH SQLITE DATABASE a(?)',[event],cb);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alasql",
"description": "Alasql - JavaScript SQL database and data manipulation library",
"version": "0.0.44",
"version": "0.0.45",
"author": "Andrey Gershun <[email protected]>",
"directories": {
"example": "examples",
Expand Down
2 changes: 1 addition & 1 deletion src/05copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// alasql.js
// AlaSQL - JavaScript SQL database
// Date: 13.04.2015
// Version: 0.0.44
// Version: 0.0.45
// (ñ) 2014-2015, Andrey Gershun
//

Expand Down
164 changes: 82 additions & 82 deletions src/10start.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@

/**
UMD envelope
*/

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.alasql = factory();
}
}(this, function () {

/**
alasql - Main Alasql class
@param {string | Object} sql SQL-statement or data object for fuent interface
@param {Object} params SQL parameters
@param {Function} cb callback function
@param {Object} scope Scope for nested queries
@return {array} Result data object
Standard sync call:
alasql('CREATE TABLE one');
Query:
var res = alasql('SELECT * FROM one');
Call with parameters:
var res = alasql('SELECT * FROM ?',[data]);
Standard async call with callback function:
alasql('SELECT * FROM ?',[data],function(res){
console.log(data);
});
Call with scope for subquery (to pass common values):
var scope = {one:{a:2,b;20}}
alasql('SELECT * FROM ? two WHERE two.a = one.a',[data],null,scope);
Call for fluent interface with data object:
alasql(data).Where(function(x){return x.a == 10}).exec();
Call for fluent interface without data object:
alasql().From(data).Where(function(x){return x.a == 10}).exec();
*/

var alasql = function(sql, params, cb, scope) {
if(typeof importScripts != 'function' && alasql.webworker) {
var id = alasql.lastid++;
alasql.buffer[id] = cb;
alasql.webworker.postMessage({id:id,sql:sql,params:params});
} else {
if(arguments.length == 0) {
// Without arguments - Fluent interface
return new yy.Select({
columns:[new yy.Column({columnid:'*'})],
from: [new yy.ParamValue({param:0})]
});
} else if (arguments.length == 1 && typeof sql == "object" && sql instanceof Array) {
// One argument data object - fluent interface
var select = new yy.Select({
columns:[new yy.Column({columnid:'*'})],
from: [new yy.ParamValue({param:0})]
});
select.preparams = [sql];
return select;
} else {
// Standard interface
// alasql('#sql');
if(typeof sql == 'string' && sql[0]=='#' && typeof document == "object") {
sql = document.querySelector(sql).textContent;
} else if(typeof sql == 'object' && sql instanceof HTMElement) {
sql = sql.textContent;
} else if(typeof sql == 'function') {
// to run multiline functions
sql = sql.toString().slice(14,-3);
}
// Run SQL
return alasql.exec(sql, params, cb, scope);
}
};
};

/** Current version of alasql */
alasql.version = "0.0.44";

/**
UMD envelope
*/

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.alasql = factory();
}
}(this, function () {

/**
alasql - Main Alasql class
@param {string | Object} sql SQL-statement or data object for fuent interface
@param {Object} params SQL parameters
@param {Function} cb callback function
@param {Object} scope Scope for nested queries
@return {array} Result data object
Standard sync call:
alasql('CREATE TABLE one');
Query:
var res = alasql('SELECT * FROM one');
Call with parameters:
var res = alasql('SELECT * FROM ?',[data]);
Standard async call with callback function:
alasql('SELECT * FROM ?',[data],function(res){
console.log(data);
});
Call with scope for subquery (to pass common values):
var scope = {one:{a:2,b;20}}
alasql('SELECT * FROM ? two WHERE two.a = one.a',[data],null,scope);
Call for fluent interface with data object:
alasql(data).Where(function(x){return x.a == 10}).exec();
Call for fluent interface without data object:
alasql().From(data).Where(function(x){return x.a == 10}).exec();
*/

var alasql = function(sql, params, cb, scope) {
if(typeof importScripts != 'function' && alasql.webworker) {
var id = alasql.lastid++;
alasql.buffer[id] = cb;
alasql.webworker.postMessage({id:id,sql:sql,params:params});
} else {
if(arguments.length == 0) {
// Without arguments - Fluent interface
return new yy.Select({
columns:[new yy.Column({columnid:'*'})],
from: [new yy.ParamValue({param:0})]
});
} else if (arguments.length == 1 && typeof sql == "object" && sql instanceof Array) {
// One argument data object - fluent interface
var select = new yy.Select({
columns:[new yy.Column({columnid:'*'})],
from: [new yy.ParamValue({param:0})]
});
select.preparams = [sql];
return select;
} else {
// Standard interface
// alasql('#sql');
if(typeof sql == 'string' && sql[0]=='#' && typeof document == "object") {
sql = document.querySelector(sql).textContent;
} else if(typeof sql == 'object' && sql instanceof HTMElement) {
sql = sql.textContent;
} else if(typeof sql == 'function') {
// to run multiline functions
sql = sql.toString().slice(14,-3);
}
// Run SQL
return alasql.exec(sql, params, cb, scope);
}
};
};

/** Current version of alasql */
alasql.version = "0.0.45";

0 comments on commit 00cf108

Please sign in to comment.