@scx-js/scx-data 0.2.1 → 0.2.2
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/field_policy/AssignField.js +39 -0
- package/field_policy/FieldPolicy.js +34 -12
- package/field_policy/FieldPolicyBuilder.js +16 -16
- package/field_policy/FieldPolicyImpl.js +61 -40
- package/field_policy/FieldPolicyLike.js +111 -0
- package/field_policy/VirtualField.js +39 -0
- package/field_policy/serializer/FieldPolicySerializer.js +30 -5
- package/index.js +6 -7
- package/package.json +2 -2
- package/query/BuildControl.js +45 -0
- package/query/Condition.js +74 -0
- package/query/{WhereType.js → ConditionType.js} +0 -10
- package/query/Junction.js +25 -22
- package/query/OrderBy.js +9 -10
- package/query/Query.js +8 -23
- package/query/QueryBuilder.js +49 -44
- package/query/QueryImpl.js +31 -64
- package/query/QueryLike.js +7 -17
- package/query/SkipIfInfo.js +42 -0
- package/query/WhereClause.js +6 -16
- package/query/serializer/QuerySerializer.js +113 -15
- package/query/GroupBy.js +0 -36
- package/query/QueryOption.js +0 -74
- package/query/Where.js +0 -59
- package/query/serializer/GroupBySerializer.js +0 -50
- package/query/serializer/OrderBySerializer.js +0 -54
- package/query/serializer/WhereSerializer.js +0 -100
@@ -0,0 +1,74 @@
|
|
1
|
+
import {QueryLike} from "./QueryLike.js";
|
2
|
+
import {isBlank} from "@scx-js/scx-common";
|
3
|
+
import {QueryImpl} from "./QueryImpl.js";
|
4
|
+
|
5
|
+
class Condition extends QueryLike {
|
6
|
+
|
7
|
+
#selector;
|
8
|
+
#conditionType;
|
9
|
+
#value1;
|
10
|
+
#value2;
|
11
|
+
#useExpression;
|
12
|
+
#useExpressionValue;
|
13
|
+
#skipIfInfo;
|
14
|
+
|
15
|
+
constructor(selector, conditionType, value1, value2, useExpression, useExpressionValue, skipIfInfo) {
|
16
|
+
super();
|
17
|
+
//名称不能为空
|
18
|
+
if (isBlank(selector)) {
|
19
|
+
throw new Error("Where 参数错误 : 名称 不能为空 !!!");
|
20
|
+
}
|
21
|
+
//类型也不能为空
|
22
|
+
if (conditionType == null) {
|
23
|
+
throw new Error("Where 参数错误 : whereType 不能为空 !!!");
|
24
|
+
}
|
25
|
+
this.#selector = selector;
|
26
|
+
this.#conditionType = conditionType;
|
27
|
+
this.#value1 = value1;
|
28
|
+
this.#value2 = value2;
|
29
|
+
this.#useExpression = useExpression;
|
30
|
+
this.#useExpressionValue = useExpressionValue;
|
31
|
+
this.#skipIfInfo = skipIfInfo;
|
32
|
+
}
|
33
|
+
|
34
|
+
selector() {
|
35
|
+
return this.#selector;
|
36
|
+
}
|
37
|
+
|
38
|
+
conditionType() {
|
39
|
+
return this.#conditionType;
|
40
|
+
}
|
41
|
+
|
42
|
+
value1() {
|
43
|
+
return this.#value1;
|
44
|
+
}
|
45
|
+
|
46
|
+
value2() {
|
47
|
+
return this.#value2;
|
48
|
+
}
|
49
|
+
|
50
|
+
useExpression() {
|
51
|
+
return this.#useExpression;
|
52
|
+
}
|
53
|
+
|
54
|
+
useExpressionValue() {
|
55
|
+
return this.#useExpressionValue;
|
56
|
+
}
|
57
|
+
|
58
|
+
skipIfInfo() {
|
59
|
+
return this.#skipIfInfo;
|
60
|
+
}
|
61
|
+
|
62
|
+
isEmpty() {
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
toQuery() {
|
67
|
+
return new QueryImpl().where(this);
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
export {
|
73
|
+
Condition,
|
74
|
+
};
|
@@ -68,14 +68,6 @@ const BETWEEN = "BETWEEN";
|
|
68
68
|
*/
|
69
69
|
const NOT_BETWEEN = "NOT_BETWEEN";
|
70
70
|
|
71
|
-
/**
|
72
|
-
* json 包含 一般用于 数组判断
|
73
|
-
*/
|
74
|
-
const JSON_CONTAINS = "JSON_CONTAINS";
|
75
|
-
|
76
|
-
|
77
|
-
const JSON_OVERLAPS = "JSON_OVERLAPS";
|
78
|
-
|
79
71
|
|
80
72
|
export {
|
81
73
|
EQ,
|
@@ -92,6 +84,4 @@ export {
|
|
92
84
|
NOT_IN,
|
93
85
|
BETWEEN,
|
94
86
|
NOT_BETWEEN,
|
95
|
-
JSON_CONTAINS,
|
96
|
-
JSON_OVERLAPS,
|
97
87
|
};
|
package/query/Junction.js
CHANGED
@@ -5,8 +5,6 @@ import {
|
|
5
5
|
GT,
|
6
6
|
GTE,
|
7
7
|
IN,
|
8
|
-
JSON_CONTAINS,
|
9
|
-
JSON_OVERLAPS,
|
10
8
|
LIKE,
|
11
9
|
LIKE_REGEX,
|
12
10
|
LT,
|
@@ -16,10 +14,11 @@ import {
|
|
16
14
|
NOT_IN,
|
17
15
|
NOT_LIKE,
|
18
16
|
NOT_LIKE_REGEX,
|
19
|
-
} from "./
|
20
|
-
import {
|
21
|
-
import {QueryImpl} from "./QueryImpl.js";
|
22
|
-
import {Not} from "./Not.js";
|
17
|
+
} from "./ConditionType.js";
|
18
|
+
import {Condition} from "./Condition.js";
|
19
|
+
// import {QueryImpl} from "./QueryImpl.js";
|
20
|
+
// import {Not} from "./Not.js";
|
21
|
+
// import {WhereClause} from "./WhereClause.js";
|
23
22
|
|
24
23
|
class Junction extends QueryLike {
|
25
24
|
|
@@ -54,67 +53,67 @@ class Junction extends QueryLike {
|
|
54
53
|
}
|
55
54
|
|
56
55
|
eq(fieldName, value, ...options) {
|
57
|
-
return this.add(new
|
56
|
+
return this.add(new Condition(fieldName, EQ, value, null, ...options));
|
58
57
|
}
|
59
58
|
|
60
59
|
ne(fieldName, value, ...options) {
|
61
|
-
return this.add(new
|
60
|
+
return this.add(new Condition(fieldName, NE, value, null, ...options));
|
62
61
|
}
|
63
62
|
|
64
63
|
lt(fieldName, value, ...options) {
|
65
|
-
return this.add(new
|
64
|
+
return this.add(new Condition(fieldName, LT, value, null, ...options));
|
66
65
|
}
|
67
66
|
|
68
67
|
lte(fieldName, value, ...options) {
|
69
|
-
return this.add(new
|
68
|
+
return this.add(new Condition(fieldName, LTE, value, null, ...options));
|
70
69
|
}
|
71
70
|
|
72
71
|
gt(fieldName, value, ...options) {
|
73
|
-
return this.add(new
|
72
|
+
return this.add(new Condition(fieldName, GT, value, null, ...options));
|
74
73
|
}
|
75
74
|
|
76
75
|
gte(fieldName, value, ...options) {
|
77
|
-
return this.add(new
|
76
|
+
return this.add(new Condition(fieldName, GTE, value, null, ...options));
|
78
77
|
}
|
79
78
|
|
80
79
|
like(fieldName, value, ...options) {
|
81
|
-
return this.add(new
|
80
|
+
return this.add(new Condition(fieldName, LIKE, value, null, ...options));
|
82
81
|
}
|
83
82
|
|
84
83
|
notLike(fieldName, value, ...options) {
|
85
|
-
return this.add(new
|
84
|
+
return this.add(new Condition(fieldName, NOT_LIKE, value, null, ...options));
|
86
85
|
}
|
87
86
|
|
88
87
|
likeRegex(fieldName, value, ...options) {
|
89
|
-
return this.add(new
|
88
|
+
return this.add(new Condition(fieldName, LIKE_REGEX, value, null, ...options));
|
90
89
|
}
|
91
90
|
|
92
91
|
notLikeRegex(fieldName, value, ...options) {
|
93
|
-
return this.add(new
|
92
|
+
return this.add(new Condition(fieldName, NOT_LIKE_REGEX, value, null, ...options));
|
94
93
|
}
|
95
94
|
|
96
95
|
in(fieldName, value, ...options) {
|
97
|
-
return this.add(new
|
96
|
+
return this.add(new Condition(fieldName, IN, value, null, ...options));
|
98
97
|
}
|
99
98
|
|
100
99
|
notIn(fieldName, value, ...options) {
|
101
|
-
return this.add(new
|
100
|
+
return this.add(new Condition(fieldName, NOT_IN, value, null, ...options));
|
102
101
|
}
|
103
102
|
|
104
103
|
between(fieldName, value1, value2, ...options) {
|
105
|
-
return this.add(new
|
104
|
+
return this.add(new Condition(fieldName, BETWEEN, value1, value2, ...options));
|
106
105
|
}
|
107
106
|
|
108
107
|
notBetween(fieldName, value1, value2, ...options) {
|
109
|
-
return this.add(new
|
108
|
+
return this.add(new Condition(fieldName, NOT_BETWEEN, value1, value2, ...options));
|
110
109
|
}
|
111
110
|
|
112
111
|
jsonContains(fieldName, value, ...options) {
|
113
|
-
return this.add(new
|
112
|
+
return this.add(new Condition(fieldName, JSON_CONTAINS, value, null, ...options));
|
114
113
|
}
|
115
114
|
|
116
115
|
jsonOverlaps(fieldName, value, ...options) {
|
117
|
-
return this.add(new
|
116
|
+
return this.add(new Condition(fieldName, JSON_OVERLAPS, value, null, ...options));
|
118
117
|
}
|
119
118
|
|
120
119
|
and(...clauses) {
|
@@ -129,6 +128,10 @@ class Junction extends QueryLike {
|
|
129
128
|
return this.add(new Not(clause));
|
130
129
|
}
|
131
130
|
|
131
|
+
whereClause(expression, ...params) {
|
132
|
+
return this.add(new WhereClause(expression, params));
|
133
|
+
}
|
134
|
+
|
132
135
|
toQuery() {
|
133
136
|
return new QueryImpl().where(this);
|
134
137
|
}
|
package/query/OrderBy.js
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
import {isBlank} from "@scx-js/scx-common";
|
2
2
|
import {QueryImpl} from "./QueryImpl.js";
|
3
|
-
import {ofInfo} from "./QueryOption.js";
|
4
3
|
import {QueryLike} from "./QueryLike.js";
|
5
4
|
|
6
5
|
class OrderBy extends QueryLike {
|
7
6
|
|
8
|
-
#
|
7
|
+
#selector;
|
9
8
|
#orderByType;
|
10
|
-
#
|
9
|
+
#useExpression;
|
11
10
|
|
12
|
-
constructor(name, orderByType,
|
11
|
+
constructor(name, orderByType, useExpression) {
|
13
12
|
super();
|
14
13
|
if (isBlank(name)) {
|
15
14
|
throw new Error("OrderBy 参数错误 : 名称 不能为空 !!!");
|
@@ -17,22 +16,22 @@ class OrderBy extends QueryLike {
|
|
17
16
|
if (orderByType == null) {
|
18
17
|
throw new Error("OrderBy 参数错误 : orderByType 不能为空 !!!");
|
19
18
|
}
|
20
|
-
this.#
|
19
|
+
this.#selector = name;
|
21
20
|
this.#orderByType = orderByType;
|
22
|
-
this.#
|
21
|
+
this.#useExpression = useExpression;
|
23
22
|
}
|
24
23
|
|
25
24
|
|
26
|
-
|
27
|
-
return this.#
|
25
|
+
selector() {
|
26
|
+
return this.#selector;
|
28
27
|
}
|
29
28
|
|
30
29
|
orderByType() {
|
31
30
|
return this.#orderByType;
|
32
31
|
}
|
33
32
|
|
34
|
-
|
35
|
-
return this.#
|
33
|
+
useExpression() {
|
34
|
+
return this.#useExpression;
|
36
35
|
}
|
37
36
|
|
38
37
|
toQuery() {
|
package/query/Query.js
CHANGED
@@ -4,29 +4,22 @@ class Query {
|
|
4
4
|
return this;
|
5
5
|
}
|
6
6
|
|
7
|
-
|
7
|
+
orderBys(...orderBys) {
|
8
8
|
return this;
|
9
9
|
}
|
10
10
|
|
11
|
-
|
11
|
+
offset(offset) {
|
12
12
|
return this;
|
13
13
|
}
|
14
14
|
|
15
|
-
|
16
|
-
return this;
|
17
|
-
}
|
18
|
-
|
19
|
-
limit(numberOfRows) {
|
15
|
+
limit(limit) {
|
20
16
|
return this;
|
21
17
|
}
|
22
18
|
|
23
19
|
getWhere() {
|
24
20
|
}
|
25
21
|
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
getOrderBy() {
|
22
|
+
getOrderBys() {
|
30
23
|
}
|
31
24
|
|
32
25
|
getOffset() {
|
@@ -39,11 +32,7 @@ class Query {
|
|
39
32
|
return this;
|
40
33
|
}
|
41
34
|
|
42
|
-
|
43
|
-
return this;
|
44
|
-
}
|
45
|
-
|
46
|
-
clearOrderBy() {
|
35
|
+
clearOrderBys() {
|
47
36
|
return this;
|
48
37
|
}
|
49
38
|
|
@@ -55,19 +44,15 @@ class Query {
|
|
55
44
|
return this;
|
56
45
|
}
|
57
46
|
|
58
|
-
|
59
|
-
return this;
|
60
|
-
}
|
61
|
-
|
62
|
-
addOrderBy(...orderByClauses) {
|
47
|
+
orderBy(...orderBys) {
|
63
48
|
return this;
|
64
49
|
}
|
65
50
|
|
66
|
-
|
51
|
+
asc(selector, ...controls) {
|
67
52
|
return this;
|
68
53
|
}
|
69
54
|
|
70
|
-
|
55
|
+
desc(selector, ...controls) {
|
71
56
|
return this;
|
72
57
|
}
|
73
58
|
|
package/query/QueryBuilder.js
CHANGED
@@ -5,8 +5,6 @@ import {
|
|
5
5
|
GT,
|
6
6
|
GTE,
|
7
7
|
IN,
|
8
|
-
JSON_CONTAINS,
|
9
|
-
JSON_OVERLAPS,
|
10
8
|
LIKE,
|
11
9
|
LIKE_REGEX,
|
12
10
|
LT,
|
@@ -16,14 +14,16 @@ import {
|
|
16
14
|
NOT_IN,
|
17
15
|
NOT_LIKE,
|
18
16
|
NOT_LIKE_REGEX,
|
19
|
-
} from "./
|
20
|
-
import {
|
17
|
+
} from "./ConditionType.js";
|
18
|
+
import {Condition} from "./Condition.js";
|
21
19
|
import {QueryImpl} from "./QueryImpl.js";
|
22
20
|
import {OrderBy} from "./OrderBy.js";
|
23
21
|
import {ASC, DESC} from "./OrderByType.js";
|
24
22
|
import {Not} from "./Not.js";
|
25
23
|
import {And} from "./And.js";
|
26
24
|
import {Or} from "./Or.js";
|
25
|
+
import {checkUseExpression, checkUseExpressionValue} from "./BuildControl.js";
|
26
|
+
import {ofSkipIfInfo} from "./SkipIfInfo.js";
|
27
27
|
|
28
28
|
function query(oldQuery) {
|
29
29
|
return new QueryImpl(oldQuery);
|
@@ -33,20 +33,16 @@ function where(whereClauses) {
|
|
33
33
|
return new QueryImpl().where(whereClauses);
|
34
34
|
}
|
35
35
|
|
36
|
-
function
|
37
|
-
return new QueryImpl().
|
36
|
+
function orderBys(...orderBys) {
|
37
|
+
return new QueryImpl().orderBys(...orderBys);
|
38
38
|
}
|
39
39
|
|
40
|
-
function
|
41
|
-
return new QueryImpl().
|
40
|
+
function offset(offset) {
|
41
|
+
return new QueryImpl().offset(offset);
|
42
42
|
}
|
43
43
|
|
44
|
-
function
|
45
|
-
return new QueryImpl().
|
46
|
-
}
|
47
|
-
|
48
|
-
function limit(numberOfRows) {
|
49
|
-
return new QueryImpl().limit(numberOfRows);
|
44
|
+
function limit(limit) {
|
45
|
+
return new QueryImpl().limit(limit);
|
50
46
|
}
|
51
47
|
|
52
48
|
function and(...clauses) {
|
@@ -61,87 +57,97 @@ function not(clause) {
|
|
61
57
|
return new Not(clause);
|
62
58
|
}
|
63
59
|
|
60
|
+
function condition(fieldName, conditionType, value, ...controls) {
|
61
|
+
let useExpression = checkUseExpression(...controls);
|
62
|
+
let useExpressionValue = checkUseExpressionValue(...controls);
|
63
|
+
let skipIfInfo = ofSkipIfInfo(...controls);
|
64
|
+
return new Condition(fieldName, conditionType, value, null, useExpression, useExpressionValue, skipIfInfo);
|
65
|
+
}
|
66
|
+
|
67
|
+
function condition2(fieldName, conditionType, value1, value2, ...controls) {
|
68
|
+
let useExpression = checkUseExpression(...controls);
|
69
|
+
let useExpressionValue = checkUseExpressionValue(...controls);
|
70
|
+
let skipIfInfo = ofSkipIfInfo(...controls);
|
71
|
+
return new Condition(fieldName, conditionType, value1, value2, useExpression, useExpressionValue, skipIfInfo);
|
72
|
+
}
|
73
|
+
|
74
|
+
function orderBy(selector, orderByType, ...controls) {
|
75
|
+
let useExpression = checkUseExpression(controls);
|
76
|
+
return new OrderBy(selector, orderByType, useExpression);
|
77
|
+
}
|
78
|
+
|
79
|
+
function whereClause(expression, ...params) {
|
80
|
+
return new WhereClause(expression, params);
|
81
|
+
}
|
82
|
+
|
64
83
|
function asc(name, ...options) {
|
65
|
-
return
|
84
|
+
return orderBy(name, ASC, ...options);
|
66
85
|
}
|
67
86
|
|
68
87
|
function desc(name, ...options) {
|
69
|
-
return
|
88
|
+
return orderBy(name, DESC, ...options);
|
70
89
|
}
|
71
90
|
|
72
91
|
function eq(fieldName, value, ...options) {
|
73
|
-
return
|
92
|
+
return condition(fieldName, EQ, value, ...options);
|
74
93
|
}
|
75
94
|
|
76
95
|
function ne(fieldName, value, ...options) {
|
77
|
-
return
|
96
|
+
return condition(fieldName, NE, value, ...options);
|
78
97
|
}
|
79
98
|
|
80
99
|
function lt(fieldName, value, ...options) {
|
81
|
-
return
|
100
|
+
return condition(fieldName, LT, value, ...options);
|
82
101
|
}
|
83
102
|
|
84
103
|
function lte(fieldName, value, ...options) {
|
85
|
-
return
|
104
|
+
return condition(fieldName, LTE, value, ...options);
|
86
105
|
}
|
87
106
|
|
88
107
|
function gt(fieldName, value, ...options) {
|
89
|
-
return
|
108
|
+
return condition(fieldName, GT, value, ...options);
|
90
109
|
}
|
91
110
|
|
92
111
|
function gte(fieldName, value, ...options) {
|
93
|
-
return
|
112
|
+
return condition(fieldName, GTE, value, ...options);
|
94
113
|
}
|
95
114
|
|
96
115
|
function like(fieldName, value, ...options) {
|
97
|
-
return
|
116
|
+
return condition(fieldName, LIKE, value, ...options);
|
98
117
|
}
|
99
118
|
|
100
119
|
function notLike(fieldName, value, ...options) {
|
101
|
-
return
|
120
|
+
return condition(fieldName, NOT_LIKE, value, ...options);
|
102
121
|
}
|
103
122
|
|
104
123
|
function likeRegex(fieldName, value, ...options) {
|
105
|
-
return
|
124
|
+
return condition(fieldName, LIKE_REGEX, value, ...options);
|
106
125
|
}
|
107
126
|
|
108
127
|
function notLikeRegex(fieldName, value, ...options) {
|
109
|
-
return
|
128
|
+
return condition(fieldName, NOT_LIKE_REGEX, value, ...options);
|
110
129
|
}
|
111
130
|
|
112
131
|
function in_(fieldName, value, ...options) {
|
113
|
-
return
|
132
|
+
return condition(fieldName, IN, value, ...options);
|
114
133
|
}
|
115
134
|
|
116
135
|
function notIn(fieldName, value, ...options) {
|
117
|
-
return
|
136
|
+
return condition(fieldName, NOT_IN, value, ...options);
|
118
137
|
}
|
119
138
|
|
120
139
|
function between(fieldName, value1, value2, ...options) {
|
121
|
-
return
|
140
|
+
return condition2(fieldName, BETWEEN, value1, value2, ...options);
|
122
141
|
}
|
123
142
|
|
124
143
|
function notBetween(fieldName, value1, value2, ...options) {
|
125
|
-
return
|
126
|
-
}
|
127
|
-
|
128
|
-
function jsonContains(fieldName, value, ...options) {
|
129
|
-
return new Where(fieldName, JSON_CONTAINS, value, null, ...options);
|
130
|
-
}
|
131
|
-
|
132
|
-
function jsonOverlaps(fieldName, value, ...options) {
|
133
|
-
return new Where(fieldName, JSON_OVERLAPS, value, null, ...options);
|
134
|
-
}
|
135
|
-
|
136
|
-
function whereClause(whereClause, params) {
|
137
|
-
return new WhereClause(whereClause, params);
|
144
|
+
return condition2(fieldName, NOT_BETWEEN, value1, value2, ...options);
|
138
145
|
}
|
139
146
|
|
140
147
|
|
141
148
|
export {
|
142
149
|
query,
|
143
150
|
where,
|
144
|
-
groupBy,
|
145
151
|
orderBy,
|
146
152
|
offset,
|
147
153
|
limit,
|
@@ -164,6 +170,5 @@ export {
|
|
164
170
|
notIn,
|
165
171
|
between,
|
166
172
|
notBetween,
|
167
|
-
jsonContains,
|
168
173
|
whereClause,
|
169
174
|
};
|
package/query/QueryImpl.js
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
import {Query} from "./Query.js";
|
2
|
-
import {
|
2
|
+
import {checkUseExpression} from "./BuildControl.js";
|
3
|
+
import {OrderBy} from "./OrderBy.js";
|
4
|
+
import {ASC, DESC} from "./OrderByType.js";
|
3
5
|
|
4
6
|
class QueryImpl extends Query {
|
5
7
|
|
6
8
|
#where;
|
7
|
-
#
|
8
|
-
#orderBy;
|
9
|
+
#orderBys;
|
9
10
|
#offset;
|
10
11
|
#limit;
|
11
12
|
|
12
|
-
|
13
13
|
/**
|
14
14
|
* 创建 Query 对象
|
15
15
|
*/
|
16
16
|
constructor(old) {
|
17
17
|
super();
|
18
18
|
this.#where = null;
|
19
|
-
this.#
|
20
|
-
this.#orderBy = [];
|
19
|
+
this.#orderBys = [];
|
21
20
|
this.#offset = null;
|
22
21
|
this.#limit = null;
|
23
22
|
}
|
@@ -27,27 +26,26 @@ class QueryImpl extends Query {
|
|
27
26
|
return this;
|
28
27
|
}
|
29
28
|
|
30
|
-
groupBy(...groupByClauses) {
|
31
|
-
this.clearGroupBy();
|
32
|
-
this.addGroupBy(...groupByClauses);
|
33
|
-
return this;
|
34
|
-
}
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
this.clearOrderBy();
|
39
|
-
this.addOrderBy(...orderByClauses);
|
30
|
+
orderBys(...orderBys) {
|
31
|
+
this.#orderBys = orderBys;
|
40
32
|
return this;
|
41
33
|
}
|
42
34
|
|
43
35
|
|
44
|
-
offset(
|
45
|
-
|
36
|
+
offset(offset) {
|
37
|
+
if (offset < 0) {
|
38
|
+
throw new Error("Limit 参数错误 : offset (偏移量) 不能小于 0 !!!");
|
39
|
+
}
|
40
|
+
this.#offset = offset;
|
46
41
|
return this;
|
47
42
|
}
|
48
43
|
|
49
|
-
limit(
|
50
|
-
|
44
|
+
limit(limit) {
|
45
|
+
if (limit < 0) {
|
46
|
+
throw new Error("Limit 参数错误 : limit (行长度) 不能小于 0 !!!");
|
47
|
+
}
|
48
|
+
this.#limit = limit;
|
51
49
|
return this;
|
52
50
|
}
|
53
51
|
|
@@ -55,12 +53,8 @@ class QueryImpl extends Query {
|
|
55
53
|
return this.#where;
|
56
54
|
}
|
57
55
|
|
58
|
-
|
59
|
-
return this.#
|
60
|
-
}
|
61
|
-
|
62
|
-
getOrderBy() {
|
63
|
-
return this.#orderBy;
|
56
|
+
getOrderBys() {
|
57
|
+
return this.#orderBys;
|
64
58
|
}
|
65
59
|
|
66
60
|
getOffset() {
|
@@ -76,13 +70,8 @@ class QueryImpl extends Query {
|
|
76
70
|
return this;
|
77
71
|
}
|
78
72
|
|
79
|
-
|
80
|
-
this.#
|
81
|
-
return this;
|
82
|
-
}
|
83
|
-
|
84
|
-
clearOrderBy() {
|
85
|
-
this.#orderBy = [];
|
73
|
+
clearOrderBys() {
|
74
|
+
this.#orderBys = [];
|
86
75
|
return this;
|
87
76
|
}
|
88
77
|
|
@@ -96,46 +85,24 @@ class QueryImpl extends Query {
|
|
96
85
|
return this;
|
97
86
|
}
|
98
87
|
|
99
|
-
|
100
|
-
|
101
|
-
if (groupByClause == null) {
|
102
|
-
continue;
|
103
|
-
}
|
104
|
-
if (Array.isArray(groupByClause)) {
|
105
|
-
this.addGroupBy(...groupByClause);
|
106
|
-
continue;
|
107
|
-
}
|
108
|
-
this.#groupBy.push(groupByClause);
|
109
|
-
}
|
88
|
+
orderBy(...orderBys) {
|
89
|
+
this.#orderBys.push(orderBys);
|
110
90
|
return this;
|
111
91
|
}
|
112
92
|
|
113
|
-
addOrderBy(...orderByClauses) {
|
114
|
-
for (let orderByClause of orderByClauses) {
|
115
|
-
if (orderByClause == null) {
|
116
|
-
continue;
|
117
|
-
}
|
118
|
-
if (Array.isArray(orderByClause)) {
|
119
|
-
this.addOrderBy(...orderByClause);
|
120
|
-
continue;
|
121
|
-
}
|
122
|
-
this.#orderBy.push(orderByClause);
|
123
|
-
}
|
124
|
-
return this;
|
125
|
-
}
|
126
93
|
|
127
|
-
|
128
|
-
|
94
|
+
asc(selector, ...controls) {
|
95
|
+
let useExpression = checkUseExpression(controls);
|
96
|
+
let o= new OrderBy(selector, ASC, useExpression);
|
97
|
+
this.orderBy(o);
|
129
98
|
return this;
|
130
99
|
}
|
131
100
|
|
132
|
-
removeGroupByIf(filter) {
|
133
|
-
removeIf(this.#groupBy, filter);
|
134
|
-
return this;
|
135
|
-
}
|
136
101
|
|
137
|
-
|
138
|
-
|
102
|
+
desc(selector, ...controls) {
|
103
|
+
let useExpression = checkUseExpression(controls);
|
104
|
+
let o= new OrderBy(selector, DESC, useExpression);
|
105
|
+
this.orderBy(o);
|
139
106
|
return this;
|
140
107
|
}
|
141
108
|
|