mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 09:24:58 +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
|
|||
![Structure](app/assets/img/structure.png)
|
||||
|
||||
## 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:paulmillr/es6-shim](https://github.com/paulmillr/es6-shim)
|
||||
- [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 || {};
|
||||
if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
|
||||
if (cache[FN]) return cache[FN];
|
||||
if (typeof(escapeToGlobal) != "boolean") escapeToGlobal = true;
|
||||
|
||||
// get directory name
|
||||
var getDirName = function(path) {
|
||||
|
@ -148,8 +153,16 @@ function require(FN) {
|
|||
return;
|
||||
}
|
||||
|
||||
// make global 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;
|
||||
// make function
|
||||
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 {
|
||||
cache[FN] = eval(T);
|
||||
} catch (e) {
|
||||
|
@ -164,6 +177,13 @@ function require(FN) {
|
|||
return cache[FN];
|
||||
}
|
||||
|
||||
/**
|
||||
* @FN {string} The name of the file.
|
||||
*/
|
||||
function require(FN) {
|
||||
return _require(FN, false);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Load script, and call app.main()
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -232,21 +252,29 @@ var ModuleObject = function() {
|
|||
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
|
||||
require("app/assets/js/es5-shim-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
|
||||
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
|
||||
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-shim-0.35.5.min");
|
||||
//require("app/assets/js/es6-sham-0.35.5.min");
|
||||
|
||||
// Babel Browser Polyfill
|
||||
require("app/assets/js/babel-browser-polyfill-6.22.0");
|
||||
|
||||
// dive into entrypoint
|
||||
// Dive into entrypoint
|
||||
function main() {
|
||||
if (typeof(window) === "undefined") {
|
||||
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