0
1
Fork 0
hedera-web-mindshore/js/sql/operation.js

86 lines
1.1 KiB
JavaScript

var Expr = require('./expr');
var ListHolder = require('./list-holder');
/**
* The equivalent of a SQL operation between exprs.
*
* @param {Array#Expr} exprs Array with the exprs
* @param {Type} type The type of the operation
*/
var Klass = new Class();
module.exports = Klass;
var Type = {
EQUAL : 0
,LIKE : 1
,AND : 2
,OR : 3
,REGEXP : 4
,LOWER : 5
,UPPER : 6
,LE : 7
,UE : 8
,PLUS : 9
,MINUS : 10
,MULT : 11
,DIV : 12
,NE : 13
,MOD : 14
};
var Operators = [
'='
,'LIKE'
,'AND'
,'OR'
,'REGEXP'
,'<'
,'>'
,'<='
,'>='
,'+'
,'-'
,'*'
,'/'
,'<>'
,'MOD'
];
Klass.extend({
Type: Type
,Operators: Operators
});
Klass.implement({
Extends: Expr
,Implements: ListHolder
,Tag: 'sql-operation'
,Properties: {
type: {
enumType: Type
,value: -1
},
target: {
type: String
,value: null
},
exprs: {
type: Array
,set: function(x) {
this.list = x;
}
,get: function() {
return this.list;
}
}
}
,render: function(params) {
var operator = ' '+ Operators[this.type] +' ';
return '('
+ this.renderListWs(this.list, params, operator)
+ ')';
}
});