Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

betajs-sql

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

betajs-sql - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

.idea/betajs-sql.iml

6

dist/betajs-sql-noscoped.js
/*!
betajs-sql - v1.0.4 - 2020-06-02
betajs-sql - v1.0.6 - 2020-06-10
Copyright (c) Pablo Iglesias

@@ -15,4 +15,4 @@ Apache-2.0 Software License.

"guid": "4631f510-61c4-4a38-8065-c8e57577625b",
"version": "1.0.4",
"datetime": 1591112834001
"version": "1.0.6",
"datetime": 1591801077057
};

@@ -19,0 +19,0 @@ });

/*!
betajs-sql - v1.0.4 - 2020-06-02
betajs-sql - v1.0.6 - 2020-06-10
Copyright (c) Pablo Iglesias

@@ -7,2 +7,2 @@ Apache-2.0 Software License.

(function(){var a=this.subScope();a.binding("module","global:BetaJS.Data.Databases.Sql"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"4631f510-61c4-4a38-8065-c8e57577625b",version:"1.0.4",datetime:1591112834001}}),a.assumeVersion("base:version","undefined"),a.assumeVersion("data:version","undefined"),a.define("module:SqlDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(a){return this._table_id=a||"id",this.__req?this.__req:(this.__req=this._database.sqldb(),this.__sqlbricks=this._database.sql_bricks,this.__req)},primary_key:function(){return this._table_id},_encode:function(a){return a},_decode:function(a){return a},_find:function(a,c){var d=this.table(),f=this.__formatFind(a,c);b.create();return b.funcCallback(d,d.query,f,{}).mapSuccess(function(a){return new e(a.rows)},this).mapError(function(a){return a})},_insertRow:function(a){var c=this.table(),d=this.__formatInsertRow(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_removeRow:function(a){var c=this.table(),d=this.__formatDelete(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_updateRow:function(a,c){var d=this.table(),e=this.__formatUpdate(a,c),f=b.create();return d.query(e,{},f.asyncCallbackFunc()),f.success(function(a){return a},this).error(function(a){return a},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})},updateByData:function(a,b){return this.updateRow(a,b)},removeByData:function(a){return this.removeRow(a)},__tableName:function(){return this._table_name},__tableId:function(){return this._table_id},__formatInsertRow:function(a){return this.__getFormatter().insert(this.__tableName(),a).toParams()},__formatDelete:function(a){var b=this.__getFormatter(),c=b.delete.apply(b).from(this.__tableName());if(a){(d.is_array(a)||d.is_object(a))&&(c=this.__extractWhereParams(a,c))}return c.toParams()},__formatUpdate:function(a,b){var c=this.__getFormatter(),e=c.update(this.__tableName(),a);if(b){(d.is_array(b)||d.is_object(b))&&(e=this.__extractWhereParams(b,e))}return e.toParams()},__formatFind:function(a,b){b=b||{};var c=this.__getFormatter(),e=c.select().from(this.__tableName());if(b.distinct&&e.distinct(b.distinct),b.columns&&e.select(b.columns),a){(d.is_array(a)||d.is_object(a))&&(e=this.__extractWhereParams(a,e))}return b.groupBy&&e.groupBy(b.groupBy),b.orderBy&&e.orderBy(b.orderBy),e.toParams()},__extractWhereParams:function(a,b){return c.iter(a,function(e,f){if(c.contains_value(this.__specialWhereParams(),f))b=this.__specialWhereParam(b,f,e);else if(d.is_object(e))b.where(e);else if(a.hasOwnProperty(f)){var g={};g[f]=e,b.where(g)}},this),b},__specialWhereParam:function(a,b,e){var f=this.__getFormatter();if("or"==b)a.where(f.or(e));else if(d.is_object(e)&&!d.is_array(e)){var g=c.keys(e)[0],h=c.values(e)[0];a.where(f[b](g,h))}else d.is_array(e)&&c.iter(e,function(c,d){a=this.__specialWhereParam(a,b,c)},this);return a},__specialWhereParams:function(){return["or","eq","notEq","lt","lte","gt","gte"]},__getFormatter:function(){return this.__sqlbricks}})}),a.define("module:SqlDatabase",["data:Databases.Database","module:SqlDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=b.substring(b.indexOf("://")+3,b.length),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost"},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.sql_module=require("node-redshift"),this.sql_bricks=require("sql-bricks")},_tableClass:function(){return b},sqldb:function(){var a=this.__sqldb;if(!this.__sqldb){var b=this.sql_module,c=new b(this.__dbObject,{rawConnection:!0});this.__sqldb=c,a=c}return a},sqldbMod:function(){return this.sql_module},sqldbObj:function(){return this.__sqldb},sqldbReqObj:function(){return this.__sqldbreq},close:function(){this.__sqldb.close()}}},{uriToObject:function(a){var b=g.parse(c.strip_start(a,"jdbc:"));return{database:c.strip_start(b.path,"/"),host:b.host,port:b.port,user:b.user?b.user:b.queryKey.user?b.queryKey.user:null,password:b.password?b.password:b.queryKey.password?b.queryKey.password:null}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped);
(function(){var a=this.subScope();a.binding("module","global:BetaJS.Data.Databases.Sql"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"4631f510-61c4-4a38-8065-c8e57577625b",version:"1.0.6",datetime:1591801077057}}),a.assumeVersion("base:version","undefined"),a.assumeVersion("data:version","undefined"),a.define("module:SqlDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(a){return this._table_id=a||"id",this.__req?this.__req:(this.__req=this._database.sqldb(),this.__sqlbricks=this._database.sql_bricks,this.__req)},primary_key:function(){return this._table_id},_encode:function(a){return a},_decode:function(a){return a},_find:function(a,c){var d=this.table(),f=this.__formatFind(a,c);b.create();return b.funcCallback(d,d.query,f,{}).mapSuccess(function(a){return new e(a.rows)},this).mapError(function(a){return a})},_insertRow:function(a){var c=this.table(),d=this.__formatInsertRow(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_removeRow:function(a){var c=this.table(),d=this.__formatDelete(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_updateRow:function(a,c){var d=this.table(),e=this.__formatUpdate(a,c),f=b.create();return d.query(e,{},f.asyncCallbackFunc()),f.success(function(a){return a},this).error(function(a){return a},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})},updateByData:function(a,b){return this.updateRow(a,b)},removeByData:function(a){return this.removeRow(a)},__tableName:function(){return this._table_name},__tableId:function(){return this._table_id},__formatInsertRow:function(a){return this.__getFormatter().insert(this.__tableName(),a).toParams()},__formatDelete:function(a){var b=this.__getFormatter(),c=b.delete.apply(b).from(this.__tableName());if(a){(d.is_array(a)||d.is_object(a))&&(c=this.__extractWhereParams(a,c))}return c.toParams()},__formatUpdate:function(a,b){var c=this.__getFormatter(),e=c.update(this.__tableName(),a);if(b){(d.is_array(b)||d.is_object(b))&&(e=this.__extractWhereParams(b,e))}return e.toParams()},__formatFind:function(a,b){b=b||{};var c=this.__getFormatter(),e=c.select().from(this.__tableName());if(b.distinct&&e.distinct(b.distinct),b.columns&&e.select(b.columns),a){(d.is_array(a)||d.is_object(a))&&(e=this.__extractWhereParams(a,e))}return b.groupBy&&e.groupBy(b.groupBy),b.orderBy&&e.orderBy(b.orderBy),e.toParams()},__extractWhereParams:function(a,b){return c.iter(a,function(e,f){if(c.contains_value(this.__specialWhereParams(),f))b=this.__specialWhereParam(b,f,e);else if(d.is_object(e))b.where(e);else if(a.hasOwnProperty(f)){var g={};g[f]=e,b.where(g)}},this),b},__specialWhereParam:function(a,b,e){var f=this.__getFormatter();if("or"==b)a.where(f.or(e));else if(d.is_object(e)&&!d.is_array(e)){var g=c.keys(e)[0],h=c.values(e)[0];a.where(f[b](g,h))}else d.is_array(e)&&c.iter(e,function(c,d){a=this.__specialWhereParam(a,b,c)},this);return a},__specialWhereParams:function(){return["or","eq","notEq","lt","lte","gt","gte"]},__getFormatter:function(){return this.__sqlbricks}})}),a.define("module:SqlDatabase",["data:Databases.Database","module:SqlDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=b.substring(b.indexOf("://")+3,b.length),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost"},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.sql_module=require("node-redshift"),this.sql_bricks=require("sql-bricks")},_tableClass:function(){return b},sqldb:function(){var a=this.__sqldb;if(!this.__sqldb){var b=this.sql_module,c=new b(this.__dbObject,{rawConnection:!0});this.__sqldb=c,a=c}return a},sqldbMod:function(){return this.sql_module},sqldbObj:function(){return this.__sqldb},sqldbReqObj:function(){return this.__sqldbreq},close:function(){this.__sqldb.close()}}},{uriToObject:function(a){var b=g.parse(c.strip_start(a,"jdbc:"));return{database:c.strip_start(b.path,"/"),host:b.host,port:b.port,user:b.user?b.user:b.queryKey.user?b.queryKey.user:null,password:b.password?b.password:b.queryKey.password?b.queryKey.password:null}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped);
/*!
betajs-sql - v1.0.4 - 2020-06-02
betajs-sql - v1.0.6 - 2020-06-10
Copyright (c) Pablo Iglesias

@@ -1013,3 +1013,3 @@ Apache-2.0 Software License.

/*!
betajs-sql - v1.0.4 - 2020-06-02
betajs-sql - v1.0.6 - 2020-06-10
Copyright (c) Pablo Iglesias

@@ -1027,4 +1027,4 @@ Apache-2.0 Software License.

"guid": "4631f510-61c4-4a38-8065-c8e57577625b",
"version": "1.0.4",
"datetime": 1591112834001
"version": "1.0.6",
"datetime": 1591801077057
};

@@ -1031,0 +1031,0 @@ });

/*!
betajs-sql - v1.0.4 - 2020-06-02
betajs-sql - v1.0.6 - 2020-06-10
Copyright (c) Pablo Iglesias

@@ -7,2 +7,2 @@ Apache-2.0 Software License.

var Scoped=function(){function a(a){function b(a){return{route:"string"==typeof a.route?a.route:null,parent:"object"==typeof a.parent?a.parent:null,ready:"boolean"==typeof a.ready&&a.ready,children:{},watchers:[],data:{},lazy:[]}}function c(a){if(!a.ready){if(a.parent&&!a.parent.ready)return void c(a.parent);if(a.route&&a.parent&&a.route in a.parent.data){a.data=a.parent.data[a.route],a.ready=!0;for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[];for(var d in a.children)c(a.children[d])}}}function d(a){if(!a.ready){a.parent&&!a.parent.ready&&d(a.parent),a.ready=!0,a.parent&&j.tree&&"object"==typeof a.parent.data&&(a.parent.data[a.route]=a.data);for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[]}}function e(a,b){if("object"==typeof b&&a.ready)for(var e in b)a.data[e]=b[e];else a.data=b;if("object"==typeof b)for(var f in b)a.children[f]&&(a.children[f].data=b[f]);d(a);for(var g in a.children)c(a.children[g])}function f(a){if(a.ready&&a.data)for(var b in a.data)delete a.data[b]}function g(a){if(!a)return k;for(var d=a.split("."),e=k,f=0;f<d.length;++f)d[f]in e.children?e=e.children[d[f]]:(e.children[d[f]]=b({parent:e,route:d[f]}),e=e.children[d[f]],c(e));return e}function h(a,b,c){if(a.ready)b.call(c||this,a.data);else if(a.watchers.push({callback:b,context:c}),a.lazy.length>0){var d=function(a){if(a.lazy.length>0){var b=a.lazy.shift();b.callback.call(b.context||this,a.data),d(a)}};d(a)}}function i(a,b,c){a=a||k,c=c||[],!a.ready&&0===a.lazy.length&&a.watchers.length>0&&c.push(b);for(var d in a.children){var e=a.children[d];c=i(e,(b?b+".":"")+e.route,c)}return c}var j={tree:"boolean"==typeof a.tree&&a.tree,global:"boolean"==typeof a.global&&a.global,root:"object"==typeof a.root?a.root:{}},k=b({ready:!0});if(j.tree)if(j.global){try{window&&(k.data=window)}catch(a){}try{global&&(k.data=global)}catch(a){}try{self&&(k.data=self)}catch(a){}}else k.data=j.root;return{extend:function(a,b){e(g(a),b)},set:function(a,b){var c=g(a);c.data&&f(c),e(c,b)},get:function(a){var b=g(a);return b.ready?b.data:null},lazy:function(a,b,c){var d=g(a);d.ready?b(c||this,d.data):d.lazy.push({callback:b,context:c})},digest:function(a){c(g(a))},obtain:function(a,b,c){h(g(a),b,c)},unresolvedWatchers:function(a){return i(g(a),a)},__export:function(){return{options:j,nsRoot:k}},__import:function(a){j=a.options,k=a.nsRoot}}}function b(e,f,g,h){var i=null,j=[],k=f,l=g,m=h,n=a({tree:!0}),o=a({tree:!1}),p={global:{namespace:m},root:{namespace:l},local:{namespace:n},default:{namespace:o},parent:{namespace:k},scope:{namespace:n,readonly:!1}},q=function(a,b,c){var e=d.matchArgs(a,{options:"object",namespaceLocator:!0,dependencies:"array",hiddenDependencies:"array",callback:!0,context:"object"}),f=d.extend({lazy:this.options.lazy},e.options||{}),g=this.resolve(e.namespaceLocator),h=function(){this.require(e.dependencies,e.hiddenDependencies,function(){for(var f=[],h=0;h<arguments.length;++h)f.push(arguments[h]);if(f[f.length-1].ns=g,this.options.compile){for(var i=[],j=0;j<a.length;++j)i.push(d.stringify(a[j]));this.compiled+=this.options.ident+"."+b+"("+i.join(", ")+");\n\n"}this.options.dependencies&&(this.dependencies[g.path]=this.dependencies[g.path]||{},e.dependencies&&e.dependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this),e.hiddenDependencies&&e.hiddenDependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this));var k=this.options.compile?{}:e.callback.apply(e.context||this,f);c.call(this,g,k)},this)};return f.lazy?g.namespace.lazy(g.path,h,this):h.apply(this),this};return{getGlobal:d.method(c,c.getPath),setGlobal:d.method(c,c.setPath),options:{lazy:!1,ident:"Scoped",compile:!1,dependencies:!1},compiled:"",dependencies:{},nextScope:function(){return i||(i=b(this,n,l,m)),i},subScope:function(){var a=this.nextScope();return j.push(a),i=null,a},binding:function(b,c,e){if(!p[b]||!p[b].readonly){var f;f="string"!=d.typeOf(c)?{namespace:a({tree:!0,root:c}),path:null}:this.resolve(c),p[b]=d.extend(e,f)}return this},resolve:function(a){var b=a.split(":");if(1==b.length)throw"The locator '"+b[0]+"' requires a namespace.";var c=p[b[0]];if(!c)throw"The namespace '"+b[0]+"' has not been defined (yet).";return{namespace:c.namespace,path:c.path&&b[1]?c.path+"."+b[1]:c.path||b[1]}},define:function(){return q.call(this,arguments,"define",function(a,b){if(a.namespace.get(a.path))throw"Scoped namespace "+a.path+" has already been defined. Use extend to extend an existing namespace instead";a.namespace.set(a.path,b)})},assumeVersion:function(){var a=d.matchArgs(arguments,{assumption:!0,dependencies:"array",callback:!0,context:"object",error:"string"}),b=a.dependencies||[];b.unshift(a.assumption),this.require(b,function(){var b=arguments,c=b[0].replace(/[^\d\.]/g,"");b[0]=c.split(".");for(var e=0;e<b[0].length;++e)b[0][e]=parseInt(b[0][e],10);if("function"===d.typeOf(a.callback)){if(!a.callback.apply(a.context||this,a))throw"Scoped Assumption '"+a.assumption+"' failed, value is "+c+(a.error?", but assuming "+a.error:"")}else for(var f=(a.callback+"").replace(/[^\d\.]/g,"").split("."),g=0;g<Math.min(b[0].length,f.length);++g)if(parseInt(f[g],10)>b[0][g])throw"Scoped Version Assumption '"+a.assumption+"' failed, value is "+c+", but assuming at least "+a.callback})},extend:function(){return q.call(this,arguments,"extend",function(a,b){a.namespace.extend(a.path,b)})},require:function(){var a=d.matchArgs(arguments,{dependencies:"array",hiddenDependencies:"array",callback:"function",context:"object"});a.callback=a.callback||function(){};var b=a.dependencies||[],c=b.concat(a.hiddenDependencies||[]),e=c.length,f=[],g={};if(e)for(var h=function(b){this.i<f.length&&(f[this.i]=b),0===--e&&(f.push(g),a.callback.apply(a.context||this.ctx,f))},i=0;i<c.length;++i){var j=this.resolve(c[i]);i<b.length&&f.push(null),j.namespace.obtain(j.path,h,{ctx:this,i:i})}else f.push(g),a.callback.apply(a.context||this,f);return this},digest:function(a){var b=this.resolve(a);return b.namespace.digest(b.path),this},unresolved:function(a){var b=this.resolve(a);return b.namespace.unresolvedWatchers(b.path)},__export:function(){return{parentNamespace:k.__export(),rootNamespace:l.__export(),globalNamespace:m.__export(),localNamespace:n.__export(),privateNamespace:o.__export()}},__import:function(a){k.__import(a.parentNamespace),l.__import(a.rootNamespace),m.__import(a.globalNamespace),n.__import(a.localNamespace),o.__import(a.privateNamespace)}}}var c=function(){return{get:function(a){return"undefined"!=typeof window?a?window[a]:window:"undefined"!=typeof global?a?global[a]:global:"undefined"!=typeof self?a?self[a]:self:void 0},set:function(a,b){return"undefined"!=typeof window&&(window[a]=b),"undefined"!=typeof global&&(global[a]=b),"undefined"!=typeof self&&(self[a]=b),b},getPath:function(a){if(!a)return this.get();var b=a.split(".");if(1==b.length)return this.get(a);for(var c=this.get(b[0]),d=1;d<b.length;++d){if(!c)return c;c=c[b[d]]}return c},setPath:function(a,b){var c=a.split(".");if(1==c.length)return this.set(a,b);for(var d=this.get(c[0])||this.set(c[0],{}),e=1;e<c.length-1;++e)c[e]in d||(d[c[e]]={}),d=d[c[e]];return d[c[c.length-1]]=b,b}}}.call(this),d=function(){return{method:function(a,b){return function(){return b.apply(a,arguments)}},extend:function(a,b){a=a||{},b=b||{};for(var c in b)a[c]=b[c];return a},typeOf:function(a){return"[object Array]"===Object.prototype.toString.call(a)?"array":typeof a},isEmpty:function(a){if(null===a||void 0===a)return!0;if("array"==this.typeOf(a))return 0===a.length;if("object"!=typeof a)return!1;for(var b in a)return!1;return!0},matchArgs:function(a,b){var c=0,d={};for(var e in b)!0===b[e]||this.typeOf(a[c])==b[e]?(d[e]=a[c],c++):"undefined"==this.typeOf(a[c])&&c++;return d},stringify:function(a){return"function"==this.typeOf(a)?""+a:JSON.stringify(a)}}}.call(this),e=function(){return{__namespace:"Scoped",__revert:null,upgrade:function(a){var b=c.get(a||e.__namespace);if(b&&"object"===d.typeOf(b)&&b.guid===this.guid&&"string"===d.typeOf(b.version)){if(!1===this.upgradable||!1===b.upgradable)return b;for(var f=this.version.split("."),g=b.version.split("."),h=!1,i=0;i<Math.min(f.length,g.length)&&(h=parseInt(f[i],10)>parseInt(g[i],10),f[i]===g[i]);++i);return h?this.attach(a):b}return this.attach(a)},attach:function(a){a&&(e.__namespace=a);var b=c.get(e.__namespace);if(b===this)return this;if(e.__revert=b,b)try{var d=b.__exportScoped();this.__exportBackup=this.__exportScoped(),this.__importScoped(d)}catch(a){}return c.set(e.__namespace,this),this},detach:function(a){return a&&c.set(e.__namespace,null),void 0!==e.__revert&&c.set(e.__namespace,e.__revert),delete e.__revert,e.__exportBackup&&this.__importScoped(e.__exportBackup),this},exports:function(a,b,c){return a=a||("undefined"!=typeof module?module:null),"object"==typeof a&&a&&"exports"in a&&(c||a.exports===this||!a.exports||d.isEmpty(a.exports))&&(a.exports=b||this),this}}}.call(this),f=a({tree:!0,global:!0}),g=a({tree:!0}),h=b(null,g,g,f),i=d.extend(h,function(){return{guid:"4b6878ee-cb6a-46b3-94ac-27d91f58d666",version:"0.0.22",upgradable:!0,upgrade:e.upgrade,attach:e.attach,detach:e.detach,exports:e.exports,__exportScoped:function(){return{globalNamespace:f.__export(),rootNamespace:g.__export(),rootScope:h.__export()}},__importScoped:function(a){f.__import(a.globalNamespace),g.__import(a.rootNamespace),h.__import(a.rootScope)}}}.call(this));return i=i.upgrade(),i.exports(),i}.call(this);(function(){var a=this.subScope();a.binding("module","global:BetaJS.Data.Databases.Sql"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"4631f510-61c4-4a38-8065-c8e57577625b",version:"1.0.4",datetime:1591112834001}}),a.assumeVersion("base:version","undefined"),a.assumeVersion("data:version","undefined"),a.define("module:SqlDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(a){return this._table_id=a||"id",this.__req?this.__req:(this.__req=this._database.sqldb(),this.__sqlbricks=this._database.sql_bricks,this.__req)},primary_key:function(){return this._table_id},_encode:function(a){return a},_decode:function(a){return a},_find:function(a,c){var d=this.table(),f=this.__formatFind(a,c);b.create();return b.funcCallback(d,d.query,f,{}).mapSuccess(function(a){return new e(a.rows)},this).mapError(function(a){return a})},_insertRow:function(a){var c=this.table(),d=this.__formatInsertRow(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_removeRow:function(a){var c=this.table(),d=this.__formatDelete(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_updateRow:function(a,c){var d=this.table(),e=this.__formatUpdate(a,c),f=b.create();return d.query(e,{},f.asyncCallbackFunc()),f.success(function(a){return a},this).error(function(a){return a},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})},updateByData:function(a,b){return this.updateRow(a,b)},removeByData:function(a){return this.removeRow(a)},__tableName:function(){return this._table_name},__tableId:function(){return this._table_id},__formatInsertRow:function(a){return this.__getFormatter().insert(this.__tableName(),a).toParams()},__formatDelete:function(a){var b=this.__getFormatter(),c=b.delete.apply(b).from(this.__tableName());if(a){(d.is_array(a)||d.is_object(a))&&(c=this.__extractWhereParams(a,c))}return c.toParams()},__formatUpdate:function(a,b){var c=this.__getFormatter(),e=c.update(this.__tableName(),a);if(b){(d.is_array(b)||d.is_object(b))&&(e=this.__extractWhereParams(b,e))}return e.toParams()},__formatFind:function(a,b){b=b||{};var c=this.__getFormatter(),e=c.select().from(this.__tableName());if(b.distinct&&e.distinct(b.distinct),b.columns&&e.select(b.columns),a){(d.is_array(a)||d.is_object(a))&&(e=this.__extractWhereParams(a,e))}return b.groupBy&&e.groupBy(b.groupBy),b.orderBy&&e.orderBy(b.orderBy),e.toParams()},__extractWhereParams:function(a,b){return c.iter(a,function(e,f){if(c.contains_value(this.__specialWhereParams(),f))b=this.__specialWhereParam(b,f,e);else if(d.is_object(e))b.where(e);else if(a.hasOwnProperty(f)){var g={};g[f]=e,b.where(g)}},this),b},__specialWhereParam:function(a,b,e){var f=this.__getFormatter();if("or"==b)a.where(f.or(e));else if(d.is_object(e)&&!d.is_array(e)){var g=c.keys(e)[0],h=c.values(e)[0];a.where(f[b](g,h))}else d.is_array(e)&&c.iter(e,function(c,d){a=this.__specialWhereParam(a,b,c)},this);return a},__specialWhereParams:function(){return["or","eq","notEq","lt","lte","gt","gte"]},__getFormatter:function(){return this.__sqlbricks}})}),a.define("module:SqlDatabase",["data:Databases.Database","module:SqlDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=b.substring(b.indexOf("://")+3,b.length),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost"},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.sql_module=require("node-redshift"),this.sql_bricks=require("sql-bricks")},_tableClass:function(){return b},sqldb:function(){var a=this.__sqldb;if(!this.__sqldb){var b=this.sql_module,c=new b(this.__dbObject,{rawConnection:!0});this.__sqldb=c,a=c}return a},sqldbMod:function(){return this.sql_module},sqldbObj:function(){return this.__sqldb},sqldbReqObj:function(){return this.__sqldbreq},close:function(){this.__sqldb.close()}}},{uriToObject:function(a){var b=g.parse(c.strip_start(a,"jdbc:"));return{database:c.strip_start(b.path,"/"),host:b.host,port:b.port,user:b.user?b.user:b.queryKey.user?b.queryKey.user:null,password:b.password?b.password:b.queryKey.password?b.queryKey.password:null}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped);
var Scoped=function(){function a(a){function b(a){return{route:"string"==typeof a.route?a.route:null,parent:"object"==typeof a.parent?a.parent:null,ready:"boolean"==typeof a.ready&&a.ready,children:{},watchers:[],data:{},lazy:[]}}function c(a){if(!a.ready){if(a.parent&&!a.parent.ready)return void c(a.parent);if(a.route&&a.parent&&a.route in a.parent.data){a.data=a.parent.data[a.route],a.ready=!0;for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[];for(var d in a.children)c(a.children[d])}}}function d(a){if(!a.ready){a.parent&&!a.parent.ready&&d(a.parent),a.ready=!0,a.parent&&j.tree&&"object"==typeof a.parent.data&&(a.parent.data[a.route]=a.data);for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[]}}function e(a,b){if("object"==typeof b&&a.ready)for(var e in b)a.data[e]=b[e];else a.data=b;if("object"==typeof b)for(var f in b)a.children[f]&&(a.children[f].data=b[f]);d(a);for(var g in a.children)c(a.children[g])}function f(a){if(a.ready&&a.data)for(var b in a.data)delete a.data[b]}function g(a){if(!a)return k;for(var d=a.split("."),e=k,f=0;f<d.length;++f)d[f]in e.children?e=e.children[d[f]]:(e.children[d[f]]=b({parent:e,route:d[f]}),e=e.children[d[f]],c(e));return e}function h(a,b,c){if(a.ready)b.call(c||this,a.data);else if(a.watchers.push({callback:b,context:c}),a.lazy.length>0){var d=function(a){if(a.lazy.length>0){var b=a.lazy.shift();b.callback.call(b.context||this,a.data),d(a)}};d(a)}}function i(a,b,c){a=a||k,c=c||[],!a.ready&&0===a.lazy.length&&a.watchers.length>0&&c.push(b);for(var d in a.children){var e=a.children[d];c=i(e,(b?b+".":"")+e.route,c)}return c}var j={tree:"boolean"==typeof a.tree&&a.tree,global:"boolean"==typeof a.global&&a.global,root:"object"==typeof a.root?a.root:{}},k=b({ready:!0});if(j.tree)if(j.global){try{window&&(k.data=window)}catch(a){}try{global&&(k.data=global)}catch(a){}try{self&&(k.data=self)}catch(a){}}else k.data=j.root;return{extend:function(a,b){e(g(a),b)},set:function(a,b){var c=g(a);c.data&&f(c),e(c,b)},get:function(a){var b=g(a);return b.ready?b.data:null},lazy:function(a,b,c){var d=g(a);d.ready?b(c||this,d.data):d.lazy.push({callback:b,context:c})},digest:function(a){c(g(a))},obtain:function(a,b,c){h(g(a),b,c)},unresolvedWatchers:function(a){return i(g(a),a)},__export:function(){return{options:j,nsRoot:k}},__import:function(a){j=a.options,k=a.nsRoot}}}function b(e,f,g,h){var i=null,j=[],k=f,l=g,m=h,n=a({tree:!0}),o=a({tree:!1}),p={global:{namespace:m},root:{namespace:l},local:{namespace:n},default:{namespace:o},parent:{namespace:k},scope:{namespace:n,readonly:!1}},q=function(a,b,c){var e=d.matchArgs(a,{options:"object",namespaceLocator:!0,dependencies:"array",hiddenDependencies:"array",callback:!0,context:"object"}),f=d.extend({lazy:this.options.lazy},e.options||{}),g=this.resolve(e.namespaceLocator),h=function(){this.require(e.dependencies,e.hiddenDependencies,function(){for(var f=[],h=0;h<arguments.length;++h)f.push(arguments[h]);if(f[f.length-1].ns=g,this.options.compile){for(var i=[],j=0;j<a.length;++j)i.push(d.stringify(a[j]));this.compiled+=this.options.ident+"."+b+"("+i.join(", ")+");\n\n"}this.options.dependencies&&(this.dependencies[g.path]=this.dependencies[g.path]||{},e.dependencies&&e.dependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this),e.hiddenDependencies&&e.hiddenDependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this));var k=this.options.compile?{}:e.callback.apply(e.context||this,f);c.call(this,g,k)},this)};return f.lazy?g.namespace.lazy(g.path,h,this):h.apply(this),this};return{getGlobal:d.method(c,c.getPath),setGlobal:d.method(c,c.setPath),options:{lazy:!1,ident:"Scoped",compile:!1,dependencies:!1},compiled:"",dependencies:{},nextScope:function(){return i||(i=b(this,n,l,m)),i},subScope:function(){var a=this.nextScope();return j.push(a),i=null,a},binding:function(b,c,e){if(!p[b]||!p[b].readonly){var f;f="string"!=d.typeOf(c)?{namespace:a({tree:!0,root:c}),path:null}:this.resolve(c),p[b]=d.extend(e,f)}return this},resolve:function(a){var b=a.split(":");if(1==b.length)throw"The locator '"+b[0]+"' requires a namespace.";var c=p[b[0]];if(!c)throw"The namespace '"+b[0]+"' has not been defined (yet).";return{namespace:c.namespace,path:c.path&&b[1]?c.path+"."+b[1]:c.path||b[1]}},define:function(){return q.call(this,arguments,"define",function(a,b){if(a.namespace.get(a.path))throw"Scoped namespace "+a.path+" has already been defined. Use extend to extend an existing namespace instead";a.namespace.set(a.path,b)})},assumeVersion:function(){var a=d.matchArgs(arguments,{assumption:!0,dependencies:"array",callback:!0,context:"object",error:"string"}),b=a.dependencies||[];b.unshift(a.assumption),this.require(b,function(){var b=arguments,c=b[0].replace(/[^\d\.]/g,"");b[0]=c.split(".");for(var e=0;e<b[0].length;++e)b[0][e]=parseInt(b[0][e],10);if("function"===d.typeOf(a.callback)){if(!a.callback.apply(a.context||this,a))throw"Scoped Assumption '"+a.assumption+"' failed, value is "+c+(a.error?", but assuming "+a.error:"")}else for(var f=(a.callback+"").replace(/[^\d\.]/g,"").split("."),g=0;g<Math.min(b[0].length,f.length);++g)if(parseInt(f[g],10)>b[0][g])throw"Scoped Version Assumption '"+a.assumption+"' failed, value is "+c+", but assuming at least "+a.callback})},extend:function(){return q.call(this,arguments,"extend",function(a,b){a.namespace.extend(a.path,b)})},require:function(){var a=d.matchArgs(arguments,{dependencies:"array",hiddenDependencies:"array",callback:"function",context:"object"});a.callback=a.callback||function(){};var b=a.dependencies||[],c=b.concat(a.hiddenDependencies||[]),e=c.length,f=[],g={};if(e)for(var h=function(b){this.i<f.length&&(f[this.i]=b),0===--e&&(f.push(g),a.callback.apply(a.context||this.ctx,f))},i=0;i<c.length;++i){var j=this.resolve(c[i]);i<b.length&&f.push(null),j.namespace.obtain(j.path,h,{ctx:this,i:i})}else f.push(g),a.callback.apply(a.context||this,f);return this},digest:function(a){var b=this.resolve(a);return b.namespace.digest(b.path),this},unresolved:function(a){var b=this.resolve(a);return b.namespace.unresolvedWatchers(b.path)},__export:function(){return{parentNamespace:k.__export(),rootNamespace:l.__export(),globalNamespace:m.__export(),localNamespace:n.__export(),privateNamespace:o.__export()}},__import:function(a){k.__import(a.parentNamespace),l.__import(a.rootNamespace),m.__import(a.globalNamespace),n.__import(a.localNamespace),o.__import(a.privateNamespace)}}}var c=function(){return{get:function(a){return"undefined"!=typeof window?a?window[a]:window:"undefined"!=typeof global?a?global[a]:global:"undefined"!=typeof self?a?self[a]:self:void 0},set:function(a,b){return"undefined"!=typeof window&&(window[a]=b),"undefined"!=typeof global&&(global[a]=b),"undefined"!=typeof self&&(self[a]=b),b},getPath:function(a){if(!a)return this.get();var b=a.split(".");if(1==b.length)return this.get(a);for(var c=this.get(b[0]),d=1;d<b.length;++d){if(!c)return c;c=c[b[d]]}return c},setPath:function(a,b){var c=a.split(".");if(1==c.length)return this.set(a,b);for(var d=this.get(c[0])||this.set(c[0],{}),e=1;e<c.length-1;++e)c[e]in d||(d[c[e]]={}),d=d[c[e]];return d[c[c.length-1]]=b,b}}}.call(this),d=function(){return{method:function(a,b){return function(){return b.apply(a,arguments)}},extend:function(a,b){a=a||{},b=b||{};for(var c in b)a[c]=b[c];return a},typeOf:function(a){return"[object Array]"===Object.prototype.toString.call(a)?"array":typeof a},isEmpty:function(a){if(null===a||void 0===a)return!0;if("array"==this.typeOf(a))return 0===a.length;if("object"!=typeof a)return!1;for(var b in a)return!1;return!0},matchArgs:function(a,b){var c=0,d={};for(var e in b)!0===b[e]||this.typeOf(a[c])==b[e]?(d[e]=a[c],c++):"undefined"==this.typeOf(a[c])&&c++;return d},stringify:function(a){return"function"==this.typeOf(a)?""+a:JSON.stringify(a)}}}.call(this),e=function(){return{__namespace:"Scoped",__revert:null,upgrade:function(a){var b=c.get(a||e.__namespace);if(b&&"object"===d.typeOf(b)&&b.guid===this.guid&&"string"===d.typeOf(b.version)){if(!1===this.upgradable||!1===b.upgradable)return b;for(var f=this.version.split("."),g=b.version.split("."),h=!1,i=0;i<Math.min(f.length,g.length)&&(h=parseInt(f[i],10)>parseInt(g[i],10),f[i]===g[i]);++i);return h?this.attach(a):b}return this.attach(a)},attach:function(a){a&&(e.__namespace=a);var b=c.get(e.__namespace);if(b===this)return this;if(e.__revert=b,b)try{var d=b.__exportScoped();this.__exportBackup=this.__exportScoped(),this.__importScoped(d)}catch(a){}return c.set(e.__namespace,this),this},detach:function(a){return a&&c.set(e.__namespace,null),void 0!==e.__revert&&c.set(e.__namespace,e.__revert),delete e.__revert,e.__exportBackup&&this.__importScoped(e.__exportBackup),this},exports:function(a,b,c){return a=a||("undefined"!=typeof module?module:null),"object"==typeof a&&a&&"exports"in a&&(c||a.exports===this||!a.exports||d.isEmpty(a.exports))&&(a.exports=b||this),this}}}.call(this),f=a({tree:!0,global:!0}),g=a({tree:!0}),h=b(null,g,g,f),i=d.extend(h,function(){return{guid:"4b6878ee-cb6a-46b3-94ac-27d91f58d666",version:"0.0.22",upgradable:!0,upgrade:e.upgrade,attach:e.attach,detach:e.detach,exports:e.exports,__exportScoped:function(){return{globalNamespace:f.__export(),rootNamespace:g.__export(),rootScope:h.__export()}},__importScoped:function(a){f.__import(a.globalNamespace),g.__import(a.rootNamespace),h.__import(a.rootScope)}}}.call(this));return i=i.upgrade(),i.exports(),i}.call(this);(function(){var a=this.subScope();a.binding("module","global:BetaJS.Data.Databases.Sql"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"4631f510-61c4-4a38-8065-c8e57577625b",version:"1.0.6",datetime:1591801077057}}),a.assumeVersion("base:version","undefined"),a.assumeVersion("data:version","undefined"),a.define("module:SqlDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(a){return this._table_id=a||"id",this.__req?this.__req:(this.__req=this._database.sqldb(),this.__sqlbricks=this._database.sql_bricks,this.__req)},primary_key:function(){return this._table_id},_encode:function(a){return a},_decode:function(a){return a},_find:function(a,c){var d=this.table(),f=this.__formatFind(a,c);b.create();return b.funcCallback(d,d.query,f,{}).mapSuccess(function(a){return new e(a.rows)},this).mapError(function(a){return a})},_insertRow:function(a){var c=this.table(),d=this.__formatInsertRow(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_removeRow:function(a){var c=this.table(),d=this.__formatDelete(a),e=b.create();return c.query(d,{},e.asyncCallbackFunc()),e.success(function(a){return a},this).error(function(a){return a},this)},_updateRow:function(a,c){var d=this.table(),e=this.__formatUpdate(a,c),f=b.create();return d.query(e,{},f.asyncCallbackFunc()),f.success(function(a){return a},this).error(function(a){return a},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})},updateByData:function(a,b){return this.updateRow(a,b)},removeByData:function(a){return this.removeRow(a)},__tableName:function(){return this._table_name},__tableId:function(){return this._table_id},__formatInsertRow:function(a){return this.__getFormatter().insert(this.__tableName(),a).toParams()},__formatDelete:function(a){var b=this.__getFormatter(),c=b.delete.apply(b).from(this.__tableName());if(a){(d.is_array(a)||d.is_object(a))&&(c=this.__extractWhereParams(a,c))}return c.toParams()},__formatUpdate:function(a,b){var c=this.__getFormatter(),e=c.update(this.__tableName(),a);if(b){(d.is_array(b)||d.is_object(b))&&(e=this.__extractWhereParams(b,e))}return e.toParams()},__formatFind:function(a,b){b=b||{};var c=this.__getFormatter(),e=c.select().from(this.__tableName());if(b.distinct&&e.distinct(b.distinct),b.columns&&e.select(b.columns),a){(d.is_array(a)||d.is_object(a))&&(e=this.__extractWhereParams(a,e))}return b.groupBy&&e.groupBy(b.groupBy),b.orderBy&&e.orderBy(b.orderBy),e.toParams()},__extractWhereParams:function(a,b){return c.iter(a,function(e,f){if(c.contains_value(this.__specialWhereParams(),f))b=this.__specialWhereParam(b,f,e);else if(d.is_object(e))b.where(e);else if(a.hasOwnProperty(f)){var g={};g[f]=e,b.where(g)}},this),b},__specialWhereParam:function(a,b,e){var f=this.__getFormatter();if("or"==b)a.where(f.or(e));else if(d.is_object(e)&&!d.is_array(e)){var g=c.keys(e)[0],h=c.values(e)[0];a.where(f[b](g,h))}else d.is_array(e)&&c.iter(e,function(c,d){a=this.__specialWhereParam(a,b,c)},this);return a},__specialWhereParams:function(){return["or","eq","notEq","lt","lte","gt","gte"]},__getFormatter:function(){return this.__sqlbricks}})}),a.define("module:SqlDatabase",["data:Databases.Database","module:SqlDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=b.substring(b.indexOf("://")+3,b.length),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost"},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.sql_module=require("node-redshift"),this.sql_bricks=require("sql-bricks")},_tableClass:function(){return b},sqldb:function(){var a=this.__sqldb;if(!this.__sqldb){var b=this.sql_module,c=new b(this.__dbObject,{rawConnection:!0});this.__sqldb=c,a=c}return a},sqldbMod:function(){return this.sql_module},sqldbObj:function(){return this.__sqldb},sqldbReqObj:function(){return this.__sqldbreq},close:function(){this.__sqldb.close()}}},{uriToObject:function(a){var b=g.parse(c.strip_start(a,"jdbc:"));return{database:c.strip_start(b.path,"/"),host:b.host,port:b.port,user:b.user?b.user:b.queryKey.user?b.queryKey.user:null,password:b.password?b.password:b.queryKey.password?b.queryKey.password:null}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped);
{
"name": "betajs-sql",
"version": "1.0.4",
"version": "1.0.6",
"description": "BetaJS-SQL is a sql wrapper for BetaJS.",

@@ -31,3 +31,4 @@ "contributors": ["Pablo Iglesias"],

"betajs-data": "~1.0.41",
"node-redshift": ""
"node-redshift": "",
"sql-bricks": ""
},

@@ -34,0 +35,0 @@ "main": "dist/betajs-sql.js",

@@ -18,3 +18,3 @@ {

"name": "betajs-sql",
"version": "1.0.5",
"version": "1.0.6",
"description": "BetaJS-SQL is a sql wrapper for BetaJS.",

@@ -49,3 +49,4 @@ "contributors": [

"betajs-data": "~1.0.41",
"node-redshift": ""
"node-redshift": "",
"sql-bricks": ""
},

@@ -52,0 +53,0 @@ "main": "dist/betajs-sql.js",

@@ -1,2 +0,2 @@

# betajs-sql 1.0.3
# betajs-sql 1.0.6
[![Code Climate](https://codeclimate.com/github/betajs/betajs-sql/badges/gpa.svg)](https://codeclimate.com/github/betajs/betajs-sql)

@@ -80,7 +80,7 @@ [![NPM](https://img.shields.io/npm/v/betajs-sql.svg?style=flat)](https://www.npmjs.com/package/betajs-sql)

| :--------- | --: |
| Homepage | [http://betajs.com](http://betajs.com) |
| Homepage | [https://betajs.com](https://betajs.com) |
| Git | [git://github.com/betajs/betajs-sql.git](git://github.com/betajs/betajs-sql.git) |
| Repository | [https://github.com/betajs/betajs-sql](https://github.com/betajs/betajs-sql) |
| Blog | [http://blog.betajs.com](http://blog.betajs.com) |
| Twitter | [http://twitter.com/thebetajs](http://twitter.com/thebetajs) |
| Blog | [https://blog.betajs.com](https://blog.betajs.com) |
| Twitter | [https://twitter.com/thebetajs](https://twitter.com/thebetajs) |

@@ -87,0 +87,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc