UNPKG

@egi/smart-db

Version:

Unified Smart DB Access

1 lines 1.72 kB
"use strict";var SmartDbSqlBuildDataType,__read=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var a,l,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(a=i.next()).done;)s.push(a.value)}catch(t){l={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(l)throw l.error}}return s},__spreadArray=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var a,l=0,i=e.length;l<i;l++)!a&&l in e||(a||(a=Array.prototype.slice.call(e,0,l)),a[l]=e[l]);return t.concat(a||Array.prototype.slice.call(e))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SmartDbSqlBuildData=exports.SmartDbSqlBuildDataType=void 0,function(t){t[t.Select=0]="Select",t[t.Insert=1]="Insert",t[t.Update=2]="Update",t[t.Delete=3]="Delete",t[t.Other=4]="Other"}(SmartDbSqlBuildDataType||(exports.SmartDbSqlBuildDataType=SmartDbSqlBuildDataType={}));var SmartDbSqlBuildData=function(){function t(t,e,r){switch(this.sql=null!=t?t:"",this.sql.substring(0,6)){case"SELECT":this.type=SmartDbSqlBuildDataType.Select;break;case"INSERT":this.type=SmartDbSqlBuildDataType.Insert;break;case"UPDATE":this.type=SmartDbSqlBuildDataType.Update;break;case"DELETE":this.type=SmartDbSqlBuildDataType.Delete;break;default:this.type=SmartDbSqlBuildDataType.Other}this.values=r||[],this.modelName=e}return t.prototype.append=function(t){this.sql=this.sql.trim()+" "+t.sql.trim(),this.values=__spreadArray(__spreadArray([],__read(this.values),!1),__read(t.values),!1)},t.prototype.toString=function(){return this.sql+" <= ("+this.values.join(", ")+")"},t.prototype.results=function(){return{sql:this.sql,values:this.values}},t}();exports.SmartDbSqlBuildData=SmartDbSqlBuildData;