@scx-js/scx-data 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/query/BuildControl.js +2 -0
- package/query/Junction.js +35 -35
- package/query/QueryBuilder.js +2 -2
- package/query/QueryImpl.js +2 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@scx-js/scx-data",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.4",
|
4
4
|
"description": "SCX Data",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "scx567888",
|
@@ -11,6 +11,6 @@
|
|
11
11
|
"url": "https://github.com/scx567888/scx-js.git"
|
12
12
|
},
|
13
13
|
"dependencies": {
|
14
|
-
"@scx-js/scx-common": "0.2.
|
14
|
+
"@scx-js/scx-common": "0.2.4"
|
15
15
|
}
|
16
16
|
}
|
package/query/BuildControl.js
CHANGED
package/query/Junction.js
CHANGED
@@ -16,9 +16,11 @@ import {
|
|
16
16
|
NOT_LIKE_REGEX,
|
17
17
|
} from "./ConditionType.js";
|
18
18
|
import {Condition} from "./Condition.js";
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
import {QueryImpl} from "./QueryImpl.js";
|
20
|
+
import {Not} from "./Not.js";
|
21
|
+
import {WhereClause} from "./WhereClause.js";
|
22
|
+
import {checkUseExpression, checkUseExpressionValue} from "./BuildControl.js";
|
23
|
+
import {ofSkipIfInfo} from "./SkipIfInfo.js";
|
22
24
|
|
23
25
|
class Junction extends QueryLike {
|
24
26
|
|
@@ -34,16 +36,7 @@ class Junction extends QueryLike {
|
|
34
36
|
}
|
35
37
|
|
36
38
|
add(...logicCauses) {
|
37
|
-
|
38
|
-
if (logicCause == null) {
|
39
|
-
continue;
|
40
|
-
}
|
41
|
-
if (Array.isArray(logicCause)) {
|
42
|
-
this.add(...logicCause);
|
43
|
-
continue;
|
44
|
-
}
|
45
|
-
this.#clauses.push(logicCause);
|
46
|
-
}
|
39
|
+
this.#clauses.push(...logicCauses);
|
47
40
|
return this;
|
48
41
|
}
|
49
42
|
|
@@ -53,67 +46,59 @@ class Junction extends QueryLike {
|
|
53
46
|
}
|
54
47
|
|
55
48
|
eq(fieldName, value, ...options) {
|
56
|
-
return this.add(
|
49
|
+
return this.add(condition(fieldName, EQ, value, ...options));
|
57
50
|
}
|
58
51
|
|
59
52
|
ne(fieldName, value, ...options) {
|
60
|
-
return this.add(
|
53
|
+
return this.add(condition(fieldName, NE, value, ...options));
|
61
54
|
}
|
62
55
|
|
63
56
|
lt(fieldName, value, ...options) {
|
64
|
-
return this.add(
|
57
|
+
return this.add(condition(fieldName, LT, value, ...options));
|
65
58
|
}
|
66
59
|
|
67
60
|
lte(fieldName, value, ...options) {
|
68
|
-
return this.add(
|
61
|
+
return this.add(condition(fieldName, LTE, value, ...options));
|
69
62
|
}
|
70
63
|
|
71
64
|
gt(fieldName, value, ...options) {
|
72
|
-
return this.add(
|
65
|
+
return this.add(condition(fieldName, GT, value, ...options));
|
73
66
|
}
|
74
67
|
|
75
68
|
gte(fieldName, value, ...options) {
|
76
|
-
return this.add(
|
69
|
+
return this.add(condition(fieldName, GTE, value, ...options));
|
77
70
|
}
|
78
71
|
|
79
72
|
like(fieldName, value, ...options) {
|
80
|
-
return this.add(
|
73
|
+
return this.add(condition(fieldName, LIKE, value, ...options));
|
81
74
|
}
|
82
75
|
|
83
76
|
notLike(fieldName, value, ...options) {
|
84
|
-
return this.add(
|
77
|
+
return this.add(condition(fieldName, NOT_LIKE, value, ...options));
|
85
78
|
}
|
86
79
|
|
87
80
|
likeRegex(fieldName, value, ...options) {
|
88
|
-
return this.add(
|
81
|
+
return this.add(condition(fieldName, LIKE_REGEX, value, ...options));
|
89
82
|
}
|
90
83
|
|
91
84
|
notLikeRegex(fieldName, value, ...options) {
|
92
|
-
return this.add(
|
85
|
+
return this.add(condition(fieldName, NOT_LIKE_REGEX, value, ...options));
|
93
86
|
}
|
94
87
|
|
95
88
|
in(fieldName, value, ...options) {
|
96
|
-
return this.add(
|
89
|
+
return this.add(condition(fieldName, IN, value, ...options));
|
97
90
|
}
|
98
91
|
|
99
92
|
notIn(fieldName, value, ...options) {
|
100
|
-
return this.add(
|
93
|
+
return this.add(condition(fieldName, NOT_IN, value, ...options));
|
101
94
|
}
|
102
95
|
|
103
96
|
between(fieldName, value1, value2, ...options) {
|
104
|
-
return this.add(
|
97
|
+
return this.add(condition2(fieldName, BETWEEN, value1, value2, ...options));
|
105
98
|
}
|
106
99
|
|
107
100
|
notBetween(fieldName, value1, value2, ...options) {
|
108
|
-
return this.add(
|
109
|
-
}
|
110
|
-
|
111
|
-
jsonContains(fieldName, value, ...options) {
|
112
|
-
return this.add(new Condition(fieldName, JSON_CONTAINS, value, null, ...options));
|
113
|
-
}
|
114
|
-
|
115
|
-
jsonOverlaps(fieldName, value, ...options) {
|
116
|
-
return this.add(new Condition(fieldName, JSON_OVERLAPS, value, null, ...options));
|
101
|
+
return this.add(condition2(fieldName, NOT_BETWEEN, value1, value2, ...options));
|
117
102
|
}
|
118
103
|
|
119
104
|
and(...clauses) {
|
@@ -138,6 +123,21 @@ class Junction extends QueryLike {
|
|
138
123
|
|
139
124
|
}
|
140
125
|
|
126
|
+
|
127
|
+
function condition(fieldName, conditionType, value, ...controls) {
|
128
|
+
let useExpression = checkUseExpression(...controls);
|
129
|
+
let useExpressionValue = checkUseExpressionValue(...controls);
|
130
|
+
let skipIfInfo = ofSkipIfInfo(...controls);
|
131
|
+
return new Condition(fieldName, conditionType, value, null, useExpression, useExpressionValue, skipIfInfo);
|
132
|
+
}
|
133
|
+
|
134
|
+
function condition2(fieldName, conditionType, value1, value2, ...controls) {
|
135
|
+
let useExpression = checkUseExpression(...controls);
|
136
|
+
let useExpressionValue = checkUseExpressionValue(...controls);
|
137
|
+
let skipIfInfo = ofSkipIfInfo(...controls);
|
138
|
+
return new Condition(fieldName, conditionType, value1, value2, useExpression, useExpressionValue, skipIfInfo);
|
139
|
+
}
|
140
|
+
|
141
141
|
export {
|
142
142
|
Junction,
|
143
143
|
};
|
package/query/QueryBuilder.js
CHANGED
@@ -72,12 +72,12 @@ function condition2(fieldName, conditionType, value1, value2, ...controls) {
|
|
72
72
|
}
|
73
73
|
|
74
74
|
function orderBy(selector, orderByType, ...controls) {
|
75
|
-
let useExpression = checkUseExpression(controls);
|
75
|
+
let useExpression = checkUseExpression(...controls);
|
76
76
|
return new OrderBy(selector, orderByType, useExpression);
|
77
77
|
}
|
78
78
|
|
79
79
|
function whereClause(expression, ...params) {
|
80
|
-
return new WhereClause(expression, params);
|
80
|
+
return new WhereClause(expression, ...params);
|
81
81
|
}
|
82
82
|
|
83
83
|
function asc(name, ...options) {
|
package/query/QueryImpl.js
CHANGED
@@ -92,7 +92,7 @@ class QueryImpl extends Query {
|
|
92
92
|
|
93
93
|
|
94
94
|
asc(selector, ...controls) {
|
95
|
-
let useExpression = checkUseExpression(controls);
|
95
|
+
let useExpression = checkUseExpression(...controls);
|
96
96
|
let o = new OrderBy(selector, ASC, useExpression);
|
97
97
|
this.orderBy(o);
|
98
98
|
return this;
|
@@ -100,7 +100,7 @@ class QueryImpl extends Query {
|
|
100
100
|
|
101
101
|
|
102
102
|
desc(selector, ...controls) {
|
103
|
-
let useExpression = checkUseExpression(controls);
|
103
|
+
let useExpression = checkUseExpression(...controls);
|
104
104
|
let o = new OrderBy(selector, DESC, useExpression);
|
105
105
|
this.orderBy(o);
|
106
106
|
return this;
|