mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 05:31:03 +00:00
Added module: SQL query builder (Squel.js)
This commit is contained in:
parent
fc09a21769
commit
4e3c52e3ee
|
@ -5,7 +5,7 @@ WelsonJS - Build a Windows desktop apps with JavaScript, HTML, and CSS based on
|
||||||

|

|
||||||
|
|
||||||
## Specifications
|
## Specifications
|
||||||
- ES6(ECMAScript 6), ES5(ECMAScript 5), JSON compatibility
|
- ES6(ECMAScript 6, Optional), ES5(ECMAScript 5), JSON compatibility
|
||||||
- [github:es-shims/es5-shim](https://github.com/es-shims/es5-shim)
|
- [github:es-shims/es5-shim](https://github.com/es-shims/es5-shim)
|
||||||
- [github:paulmillr/es6-shim](https://github.com/paulmillr/es6-shim)
|
- [github:paulmillr/es6-shim](https://github.com/paulmillr/es6-shim)
|
||||||
- [github:bestiejs/json3](https://github.com/bestiejs/json3)
|
- [github:bestiejs/json3](https://github.com/bestiejs/json3)
|
||||||
|
|
48
app.js
48
app.js
|
@ -106,10 +106,15 @@ if (typeof(CreateObject) !== "function") {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function require(FN) {
|
/**
|
||||||
|
* @FN {string} The name of the file.
|
||||||
|
* @escapeToGlobal {bool} Specifies the scope of code to execute.
|
||||||
|
*/
|
||||||
|
function _require(FN, escapeToGlobal) {
|
||||||
var cache = require.__cache = require.__cache || {};
|
var cache = require.__cache = require.__cache || {};
|
||||||
if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
|
if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
|
||||||
if (cache[FN]) return cache[FN];
|
if (cache[FN]) return cache[FN];
|
||||||
|
if (typeof(escapeToGlobal) != "boolean") escapeToGlobal = true;
|
||||||
|
|
||||||
// get directory name
|
// get directory name
|
||||||
var getDirName = function(path) {
|
var getDirName = function(path) {
|
||||||
|
@ -148,8 +153,16 @@ function require(FN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make global function
|
// make function
|
||||||
T = "(function(global){var module=new ModuleObject();return(function(exports,require,module,__filename,__dirname){" + '"use strict";' + T + "\n\nreturn module.exports})(module.exports,global.require,module,__filename,__dirname)})(this);\n\n////@ sourceURL=" + FN;
|
if (!escapeToGlobal) {
|
||||||
|
T = "(function(global){var module=new ModuleObject();return(function(exports,require,module,__filename,__dirname){"
|
||||||
|
+ '"use strict";'
|
||||||
|
+ T
|
||||||
|
+ "\n\nreturn module.exports})(module.exports,global.require,module,__filename,__dirname)})(this);\n\n////@ sourceURL="
|
||||||
|
+ FN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute function
|
||||||
try {
|
try {
|
||||||
cache[FN] = eval(T);
|
cache[FN] = eval(T);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -164,6 +177,13 @@ function require(FN) {
|
||||||
return cache[FN];
|
return cache[FN];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @FN {string} The name of the file.
|
||||||
|
*/
|
||||||
|
function require(FN) {
|
||||||
|
return _require(FN, false);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
// Load script, and call app.main()
|
// Load script, and call app.main()
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -232,21 +252,29 @@ var ModuleObject = function() {
|
||||||
this.exports = {};
|
this.exports = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// JSON 2
|
||||||
|
_require("app/assets/js/json2");
|
||||||
|
|
||||||
|
// Babel Browser Polyfill (6.22.0)
|
||||||
|
require("app/assets/js/babel-browser-polyfill-6.22.0");
|
||||||
|
|
||||||
// ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines
|
// ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines
|
||||||
require("app/assets/js/es5-shim-4.5.14.min");
|
require("app/assets/js/es5-shim-4.5.14.min");
|
||||||
require("app/assets/js/es5-sham-4.5.14.min");
|
require("app/assets/js/es5-sham-4.5.14.min");
|
||||||
|
|
||||||
|
// Squel.js SQL query string builder for Javascript
|
||||||
|
var squel = require("app/assets/js/welsonjs-squel-basic-afa1cb5-modified");
|
||||||
|
|
||||||
|
// (Optional)
|
||||||
// JSON 3 was a JSON polyfill for older JavaScript platforms
|
// JSON 3 was a JSON polyfill for older JavaScript platforms
|
||||||
var JSON = require("app/assets/js/json3-3.3.2.min");
|
//var JSON = require("app/assets/js/json3-3.3.2.min");
|
||||||
|
|
||||||
|
// (Optional)
|
||||||
// ECMAScript 6 compatibility shims for legacy JS engines
|
// ECMAScript 6 compatibility shims for legacy JS engines
|
||||||
require("app/assets/js/es6-shim-0.35.5.min");
|
//require("app/assets/js/es6-shim-0.35.5.min");
|
||||||
require("app/assets/js/es6-sham-0.35.5.min");
|
//require("app/assets/js/es6-sham-0.35.5.min");
|
||||||
|
|
||||||
// Babel Browser Polyfill
|
// Dive into entrypoint
|
||||||
require("app/assets/js/babel-browser-polyfill-6.22.0");
|
|
||||||
|
|
||||||
// dive into entrypoint
|
|
||||||
function main() {
|
function main() {
|
||||||
if (typeof(window) === "undefined") {
|
if (typeof(window) === "undefined") {
|
||||||
init_console();
|
init_console();
|
||||||
|
|
3069
app/assets/js/welsonjs-squel-basic-afa1cb5-modified.js
Normal file
3069
app/assets/js/welsonjs-squel-basic-afa1cb5-modified.js
Normal file
File diff suppressed because it is too large
Load Diff
10
sqlquerystring.js
Normal file
10
sqlquerystring.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
exports.main = function() {
|
||||||
|
console.log(squel.select({ separator: "\n" })
|
||||||
|
.from("students")
|
||||||
|
.field("name")
|
||||||
|
.field("MIN(test_score)")
|
||||||
|
.field("MAX(test_score)")
|
||||||
|
.field("GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ')")
|
||||||
|
.group("name")
|
||||||
|
.toString());
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user