@sequeljs/ast
Version:
A SQL AST manager for JavaScript
26 lines • 796 B
JavaScript
import Else from './Else';
import NodeExpression from './NodeExpression';
import When from './When';
import buildQuoted from './buildQuoted';
class Case extends NodeExpression {
constructor(expression = null, defaultVal = null) {
super();
this.conditions = [];
this.default = defaultVal;
this.case = expression;
}
else(expression) {
this.default = new Else(buildQuoted(expression));
return this;
}
then(expression) {
this.conditions[this.conditions.length - 1].right = buildQuoted(expression);
return this;
}
when(condition, expression = null) {
this.conditions.push(new When(buildQuoted(condition), expression));
return this;
}
}
export default Case;
//# sourceMappingURL=Case.js.map