1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 | var FindOperator = (function () {
|
7 |
|
8 |
|
9 |
|
10 | function FindOperator(type, value, useParameter, multipleParameters) {
|
11 | if (useParameter === void 0) { useParameter = true; }
|
12 | if (multipleParameters === void 0) { multipleParameters = false; }
|
13 | this._type = type;
|
14 | this._value = value;
|
15 | this._useParameter = useParameter;
|
16 | this._multipleParameters = multipleParameters;
|
17 | }
|
18 | Object.defineProperty(FindOperator.prototype, "useParameter", {
|
19 |
|
20 |
|
21 |
|
22 | |
23 |
|
24 |
|
25 |
|
26 | get: function () {
|
27 | if (this._value instanceof FindOperator)
|
28 | return this._value.useParameter;
|
29 | return this._useParameter;
|
30 | },
|
31 | enumerable: true,
|
32 | configurable: true
|
33 | });
|
34 | Object.defineProperty(FindOperator.prototype, "multipleParameters", {
|
35 | |
36 |
|
37 |
|
38 |
|
39 | get: function () {
|
40 | if (this._value instanceof FindOperator)
|
41 | return this._value.multipleParameters;
|
42 | return this._multipleParameters;
|
43 | },
|
44 | enumerable: true,
|
45 | configurable: true
|
46 | });
|
47 | Object.defineProperty(FindOperator.prototype, "value", {
|
48 | |
49 |
|
50 |
|
51 | get: function () {
|
52 | if (this._value instanceof FindOperator)
|
53 | return this._value.value;
|
54 | return this._value;
|
55 | },
|
56 | enumerable: true,
|
57 | configurable: true
|
58 | });
|
59 |
|
60 |
|
61 |
|
62 | |
63 |
|
64 |
|
65 | FindOperator.prototype.toSql = function (connection, aliasPath, parameters) {
|
66 | switch (this._type) {
|
67 | case "not":
|
68 | if (this._value instanceof FindOperator) {
|
69 | return "NOT(" + this._value.toSql(connection, aliasPath, parameters) + ")";
|
70 | }
|
71 | else {
|
72 | return aliasPath + " != " + parameters[0];
|
73 | }
|
74 | case "lessThan":
|
75 | return aliasPath + " < " + parameters[0];
|
76 | case "lessThanOrEqual":
|
77 | return aliasPath + " <= " + parameters[0];
|
78 | case "moreThan":
|
79 | return aliasPath + " > " + parameters[0];
|
80 | case "moreThanOrEqual":
|
81 | return aliasPath + " >= " + parameters[0];
|
82 | case "equal":
|
83 | return aliasPath + " = " + parameters[0];
|
84 | case "like":
|
85 | return aliasPath + " LIKE " + parameters[0];
|
86 | case "between":
|
87 | return aliasPath + " BETWEEN " + parameters[0] + " AND " + parameters[1];
|
88 | case "in":
|
89 | return aliasPath + " IN (" + parameters.join(", ") + ")";
|
90 | case "any":
|
91 | return aliasPath + " = ANY(" + parameters[0] + ")";
|
92 | case "isNull":
|
93 | return aliasPath + " IS NULL";
|
94 | case "raw":
|
95 | if (this.value instanceof Function) {
|
96 | return this.value(aliasPath);
|
97 | }
|
98 | else {
|
99 | return aliasPath + " = " + this.value;
|
100 | }
|
101 | }
|
102 | return "";
|
103 | };
|
104 | return FindOperator;
|
105 | }());
|
106 | exports.FindOperator = FindOperator;
|
107 |
|
108 |
|