@scx-js/scx-data 0.0.1 → 0.0.3
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_filter/FieldFilter.js +40 -40
- package/field_filter/FieldFilterBuilder.js +25 -25
- package/field_filter/FieldFilterImpl.js +81 -81
- package/field_filter/FilterMode.js +5 -5
- package/field_filter/serializer/FieldFilterSerializer.js +28 -28
- package/index.js +22 -6
- package/package.json +1 -1
- package/query/GroupBy.js +36 -36
- package/query/Logic.js +144 -144
- package/query/LogicType.js +7 -7
- package/query/OrderBy.js +42 -42
- package/query/OrderByType.js +8 -8
- package/query/Query.js +60 -60
- package/query/QueryBuilder.js +176 -176
- package/query/QueryImpl.js +143 -143
- package/query/QueryLike.js +89 -89
- package/query/QueryOption.js +74 -74
- package/query/Where.js +59 -59
- package/query/WhereClause.js +43 -43
- package/query/WhereType.js +109 -109
- package/query/serializer/GroupBySerializer.js +50 -50
- package/query/serializer/OrderBySerializer.js +54 -54
- package/query/serializer/QuerySerializer.js +35 -35
- package/query/serializer/WhereSerializer.js +79 -79
package/query/Logic.js
CHANGED
@@ -1,144 +1,144 @@
|
|
1
|
-
import {QueryLike} from "./QueryLike.js";
|
2
|
-
import {
|
3
|
-
BETWEEN,
|
4
|
-
EQUAL,
|
5
|
-
GREATER_THAN,
|
6
|
-
GREATER_THAN_OR_EQUAL,
|
7
|
-
IN,
|
8
|
-
IS_NOT_NULL,
|
9
|
-
IS_NULL,
|
10
|
-
JSON_CONTAINS,
|
11
|
-
JSON_OVERLAPS,
|
12
|
-
LESS_THAN,
|
13
|
-
LESS_THAN_OR_EQUAL,
|
14
|
-
LIKE,
|
15
|
-
LIKE_REGEX,
|
16
|
-
NOT_BETWEEN,
|
17
|
-
NOT_EQUAL,
|
18
|
-
NOT_IN,
|
19
|
-
NOT_LIKE,
|
20
|
-
NOT_LIKE_REGEX,
|
21
|
-
} from "./WhereType.js";
|
22
|
-
import {Where} from "./Where.js";
|
23
|
-
import {QueryImpl} from "./QueryImpl.js";
|
24
|
-
|
25
|
-
class Logic extends QueryLike {
|
26
|
-
|
27
|
-
#logicType;
|
28
|
-
#clauses;
|
29
|
-
|
30
|
-
constructor(logicType) {
|
31
|
-
super();
|
32
|
-
this.#logicType = logicType;
|
33
|
-
this.#clauses = [];
|
34
|
-
}
|
35
|
-
|
36
|
-
logicType() {
|
37
|
-
return this.#logicType;
|
38
|
-
}
|
39
|
-
|
40
|
-
clauses() {
|
41
|
-
return this.#clauses;
|
42
|
-
}
|
43
|
-
|
44
|
-
add(...logicCauses) {
|
45
|
-
for (let logicCause of logicCauses) {
|
46
|
-
if (logicCause == null) {
|
47
|
-
continue;
|
48
|
-
}
|
49
|
-
if (Array.isArray(logicCause)) {
|
50
|
-
this.add(...logicCause);
|
51
|
-
continue;
|
52
|
-
}
|
53
|
-
this.#clauses.push(logicCause);
|
54
|
-
}
|
55
|
-
return this;
|
56
|
-
}
|
57
|
-
|
58
|
-
clear() {
|
59
|
-
this.#clauses = [];
|
60
|
-
return this;
|
61
|
-
}
|
62
|
-
|
63
|
-
eq(fieldName, value, ...options) {
|
64
|
-
return this.add(new Where(fieldName, EQUAL, value, null, ...options));
|
65
|
-
}
|
66
|
-
|
67
|
-
ne(fieldName, value, ...options) {
|
68
|
-
return this.add(new Where(fieldName, NOT_EQUAL, value, null, ...options));
|
69
|
-
}
|
70
|
-
|
71
|
-
lt(fieldName, value, ...options) {
|
72
|
-
return this.add(new Where(fieldName, LESS_THAN, value, null, ...options));
|
73
|
-
}
|
74
|
-
|
75
|
-
le(fieldName, value, ...options) {
|
76
|
-
return this.add(new Where(fieldName, LESS_THAN_OR_EQUAL, value, null, ...options));
|
77
|
-
}
|
78
|
-
|
79
|
-
gt(fieldName, value, ...options) {
|
80
|
-
return this.add(new Where(fieldName, GREATER_THAN, value, null, ...options));
|
81
|
-
}
|
82
|
-
|
83
|
-
ge(fieldName, value, ...options) {
|
84
|
-
return this.add(new Where(fieldName, GREATER_THAN_OR_EQUAL, value, null, ...options));
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
isNull(fieldName, ...options) {
|
89
|
-
return this.add(new Where(fieldName, IS_NULL, null, null, ...options));
|
90
|
-
}
|
91
|
-
|
92
|
-
isNotNull(fieldName, ...options) {
|
93
|
-
return this.add(new Where(fieldName, IS_NOT_NULL, null, null, ...options));
|
94
|
-
}
|
95
|
-
|
96
|
-
like(fieldName, value, ...options) {
|
97
|
-
return this.add(new Where(fieldName, LIKE, value, null, ...options));
|
98
|
-
}
|
99
|
-
|
100
|
-
notLike(fieldName, value, ...options) {
|
101
|
-
return this.add(new Where(fieldName, NOT_LIKE, value, null, ...options));
|
102
|
-
}
|
103
|
-
|
104
|
-
likeRegex(fieldName, value, ...options) {
|
105
|
-
return this.add(new Where(fieldName, LIKE_REGEX, value, null, ...options));
|
106
|
-
}
|
107
|
-
|
108
|
-
notLikeRegex(fieldName, value, ...options) {
|
109
|
-
return this.add(new Where(fieldName, NOT_LIKE_REGEX, value, null, ...options));
|
110
|
-
}
|
111
|
-
|
112
|
-
in(fieldName, value, ...options) {
|
113
|
-
return this.add(new Where(fieldName, IN, value, null, ...options));
|
114
|
-
}
|
115
|
-
|
116
|
-
notIn(fieldName, value, ...options) {
|
117
|
-
return this.add(new Where(fieldName, NOT_IN, value, null, ...options));
|
118
|
-
}
|
119
|
-
|
120
|
-
between(fieldName, value1, value2, ...options) {
|
121
|
-
return this.add(new Where(fieldName, BETWEEN, value1, value2, ...options));
|
122
|
-
}
|
123
|
-
|
124
|
-
notBetween(fieldName, value1, value2, ...options) {
|
125
|
-
return this.add(new Where(fieldName, NOT_BETWEEN, value1, value2, ...options));
|
126
|
-
}
|
127
|
-
|
128
|
-
jsonContains(fieldName, value, ...options) {
|
129
|
-
return this.add(new Where(fieldName, JSON_CONTAINS, value, null, ...options));
|
130
|
-
}
|
131
|
-
|
132
|
-
jsonOverlaps(fieldName, value, ...options) {
|
133
|
-
return this.add(new Where(fieldName, JSON_OVERLAPS, value, null, ...options));
|
134
|
-
}
|
135
|
-
|
136
|
-
toQuery() {
|
137
|
-
return new QueryImpl().where(this);
|
138
|
-
}
|
139
|
-
|
140
|
-
}
|
141
|
-
|
142
|
-
export {
|
143
|
-
Logic,
|
144
|
-
};
|
1
|
+
import {QueryLike} from "./QueryLike.js";
|
2
|
+
import {
|
3
|
+
BETWEEN,
|
4
|
+
EQUAL,
|
5
|
+
GREATER_THAN,
|
6
|
+
GREATER_THAN_OR_EQUAL,
|
7
|
+
IN,
|
8
|
+
IS_NOT_NULL,
|
9
|
+
IS_NULL,
|
10
|
+
JSON_CONTAINS,
|
11
|
+
JSON_OVERLAPS,
|
12
|
+
LESS_THAN,
|
13
|
+
LESS_THAN_OR_EQUAL,
|
14
|
+
LIKE,
|
15
|
+
LIKE_REGEX,
|
16
|
+
NOT_BETWEEN,
|
17
|
+
NOT_EQUAL,
|
18
|
+
NOT_IN,
|
19
|
+
NOT_LIKE,
|
20
|
+
NOT_LIKE_REGEX,
|
21
|
+
} from "./WhereType.js";
|
22
|
+
import {Where} from "./Where.js";
|
23
|
+
import {QueryImpl} from "./QueryImpl.js";
|
24
|
+
|
25
|
+
class Logic extends QueryLike {
|
26
|
+
|
27
|
+
#logicType;
|
28
|
+
#clauses;
|
29
|
+
|
30
|
+
constructor(logicType) {
|
31
|
+
super();
|
32
|
+
this.#logicType = logicType;
|
33
|
+
this.#clauses = [];
|
34
|
+
}
|
35
|
+
|
36
|
+
logicType() {
|
37
|
+
return this.#logicType;
|
38
|
+
}
|
39
|
+
|
40
|
+
clauses() {
|
41
|
+
return this.#clauses;
|
42
|
+
}
|
43
|
+
|
44
|
+
add(...logicCauses) {
|
45
|
+
for (let logicCause of logicCauses) {
|
46
|
+
if (logicCause == null) {
|
47
|
+
continue;
|
48
|
+
}
|
49
|
+
if (Array.isArray(logicCause)) {
|
50
|
+
this.add(...logicCause);
|
51
|
+
continue;
|
52
|
+
}
|
53
|
+
this.#clauses.push(logicCause);
|
54
|
+
}
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
|
58
|
+
clear() {
|
59
|
+
this.#clauses = [];
|
60
|
+
return this;
|
61
|
+
}
|
62
|
+
|
63
|
+
eq(fieldName, value, ...options) {
|
64
|
+
return this.add(new Where(fieldName, EQUAL, value, null, ...options));
|
65
|
+
}
|
66
|
+
|
67
|
+
ne(fieldName, value, ...options) {
|
68
|
+
return this.add(new Where(fieldName, NOT_EQUAL, value, null, ...options));
|
69
|
+
}
|
70
|
+
|
71
|
+
lt(fieldName, value, ...options) {
|
72
|
+
return this.add(new Where(fieldName, LESS_THAN, value, null, ...options));
|
73
|
+
}
|
74
|
+
|
75
|
+
le(fieldName, value, ...options) {
|
76
|
+
return this.add(new Where(fieldName, LESS_THAN_OR_EQUAL, value, null, ...options));
|
77
|
+
}
|
78
|
+
|
79
|
+
gt(fieldName, value, ...options) {
|
80
|
+
return this.add(new Where(fieldName, GREATER_THAN, value, null, ...options));
|
81
|
+
}
|
82
|
+
|
83
|
+
ge(fieldName, value, ...options) {
|
84
|
+
return this.add(new Where(fieldName, GREATER_THAN_OR_EQUAL, value, null, ...options));
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
isNull(fieldName, ...options) {
|
89
|
+
return this.add(new Where(fieldName, IS_NULL, null, null, ...options));
|
90
|
+
}
|
91
|
+
|
92
|
+
isNotNull(fieldName, ...options) {
|
93
|
+
return this.add(new Where(fieldName, IS_NOT_NULL, null, null, ...options));
|
94
|
+
}
|
95
|
+
|
96
|
+
like(fieldName, value, ...options) {
|
97
|
+
return this.add(new Where(fieldName, LIKE, value, null, ...options));
|
98
|
+
}
|
99
|
+
|
100
|
+
notLike(fieldName, value, ...options) {
|
101
|
+
return this.add(new Where(fieldName, NOT_LIKE, value, null, ...options));
|
102
|
+
}
|
103
|
+
|
104
|
+
likeRegex(fieldName, value, ...options) {
|
105
|
+
return this.add(new Where(fieldName, LIKE_REGEX, value, null, ...options));
|
106
|
+
}
|
107
|
+
|
108
|
+
notLikeRegex(fieldName, value, ...options) {
|
109
|
+
return this.add(new Where(fieldName, NOT_LIKE_REGEX, value, null, ...options));
|
110
|
+
}
|
111
|
+
|
112
|
+
in(fieldName, value, ...options) {
|
113
|
+
return this.add(new Where(fieldName, IN, value, null, ...options));
|
114
|
+
}
|
115
|
+
|
116
|
+
notIn(fieldName, value, ...options) {
|
117
|
+
return this.add(new Where(fieldName, NOT_IN, value, null, ...options));
|
118
|
+
}
|
119
|
+
|
120
|
+
between(fieldName, value1, value2, ...options) {
|
121
|
+
return this.add(new Where(fieldName, BETWEEN, value1, value2, ...options));
|
122
|
+
}
|
123
|
+
|
124
|
+
notBetween(fieldName, value1, value2, ...options) {
|
125
|
+
return this.add(new Where(fieldName, NOT_BETWEEN, value1, value2, ...options));
|
126
|
+
}
|
127
|
+
|
128
|
+
jsonContains(fieldName, value, ...options) {
|
129
|
+
return this.add(new Where(fieldName, JSON_CONTAINS, value, null, ...options));
|
130
|
+
}
|
131
|
+
|
132
|
+
jsonOverlaps(fieldName, value, ...options) {
|
133
|
+
return this.add(new Where(fieldName, JSON_OVERLAPS, value, null, ...options));
|
134
|
+
}
|
135
|
+
|
136
|
+
toQuery() {
|
137
|
+
return new QueryImpl().where(this);
|
138
|
+
}
|
139
|
+
|
140
|
+
}
|
141
|
+
|
142
|
+
export {
|
143
|
+
Logic,
|
144
|
+
};
|
package/query/LogicType.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
const OR = "OR";
|
2
|
-
const AND = "AND";
|
3
|
-
|
4
|
-
export {
|
5
|
-
OR,
|
6
|
-
AND,
|
7
|
-
};
|
1
|
+
const OR = "OR";
|
2
|
+
const AND = "AND";
|
3
|
+
|
4
|
+
export {
|
5
|
+
OR,
|
6
|
+
AND,
|
7
|
+
};
|
package/query/OrderBy.js
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
import {isBlank} from "
|
2
|
-
import {QueryImpl} from "./QueryImpl.js";
|
3
|
-
import {ofInfo} from "./QueryOption.js";
|
4
|
-
|
5
|
-
class OrderBy {
|
6
|
-
|
7
|
-
#name;
|
8
|
-
#orderByType;
|
9
|
-
#info;
|
10
|
-
|
11
|
-
constructor(name, orderByType, ...options) {
|
12
|
-
if (isBlank(name)) {
|
13
|
-
throw new Error("OrderBy 参数错误 : 名称 不能为空 !!!");
|
14
|
-
}
|
15
|
-
if (orderByType == null) {
|
16
|
-
throw new Error("OrderBy 参数错误 : orderByType 不能为空 !!!");
|
17
|
-
}
|
18
|
-
this.#name = name;
|
19
|
-
this.#orderByType = orderByType;
|
20
|
-
this.#info = ofInfo(...options);
|
21
|
-
}
|
22
|
-
|
23
|
-
|
24
|
-
name() {
|
25
|
-
return this.#name;
|
26
|
-
}
|
27
|
-
|
28
|
-
orderByType() {
|
29
|
-
return this.#orderByType;
|
30
|
-
}
|
31
|
-
|
32
|
-
info() {
|
33
|
-
return this.#info;
|
34
|
-
}
|
35
|
-
|
36
|
-
toQuery() {
|
37
|
-
return new QueryImpl().orderBy(this);
|
38
|
-
}
|
39
|
-
|
40
|
-
}
|
41
|
-
|
42
|
-
export {OrderBy};
|
1
|
+
import {isBlank} from "@scx-js/scx-common";
|
2
|
+
import {QueryImpl} from "./QueryImpl.js";
|
3
|
+
import {ofInfo} from "./QueryOption.js";
|
4
|
+
|
5
|
+
class OrderBy {
|
6
|
+
|
7
|
+
#name;
|
8
|
+
#orderByType;
|
9
|
+
#info;
|
10
|
+
|
11
|
+
constructor(name, orderByType, ...options) {
|
12
|
+
if (isBlank(name)) {
|
13
|
+
throw new Error("OrderBy 参数错误 : 名称 不能为空 !!!");
|
14
|
+
}
|
15
|
+
if (orderByType == null) {
|
16
|
+
throw new Error("OrderBy 参数错误 : orderByType 不能为空 !!!");
|
17
|
+
}
|
18
|
+
this.#name = name;
|
19
|
+
this.#orderByType = orderByType;
|
20
|
+
this.#info = ofInfo(...options);
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
name() {
|
25
|
+
return this.#name;
|
26
|
+
}
|
27
|
+
|
28
|
+
orderByType() {
|
29
|
+
return this.#orderByType;
|
30
|
+
}
|
31
|
+
|
32
|
+
info() {
|
33
|
+
return this.#info;
|
34
|
+
}
|
35
|
+
|
36
|
+
toQuery() {
|
37
|
+
return new QueryImpl().orderBy(this);
|
38
|
+
}
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
export {OrderBy};
|
package/query/OrderByType.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
const ASC = "ASC";
|
2
|
-
|
3
|
-
const DESC = "DESC";
|
4
|
-
|
5
|
-
export {
|
6
|
-
ASC,
|
7
|
-
DESC,
|
8
|
-
};
|
1
|
+
const ASC = "ASC";
|
2
|
+
|
3
|
+
const DESC = "DESC";
|
4
|
+
|
5
|
+
export {
|
6
|
+
ASC,
|
7
|
+
DESC,
|
8
|
+
};
|
package/query/Query.js
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
class Query {
|
2
|
-
|
3
|
-
where(...whereClauses) {
|
4
|
-
return this;
|
5
|
-
}
|
6
|
-
|
7
|
-
groupBy(...groupByClauses) {
|
8
|
-
return this;
|
9
|
-
}
|
10
|
-
|
11
|
-
orderBy(...orderByClauses) {
|
12
|
-
return this;
|
13
|
-
}
|
14
|
-
|
15
|
-
offset(limitOffset) {
|
16
|
-
return this;
|
17
|
-
}
|
18
|
-
|
19
|
-
limit(numberOfRows) {
|
20
|
-
return this;
|
21
|
-
}
|
22
|
-
|
23
|
-
getWhere() {
|
24
|
-
}
|
25
|
-
|
26
|
-
getGroupBy() {
|
27
|
-
}
|
28
|
-
|
29
|
-
getOrderBy() {
|
30
|
-
}
|
31
|
-
|
32
|
-
getOffset() {
|
33
|
-
}
|
34
|
-
|
35
|
-
getLimit() {
|
36
|
-
}
|
37
|
-
|
38
|
-
clearWhere() {
|
39
|
-
return this;
|
40
|
-
}
|
41
|
-
|
42
|
-
clearGroupBy() {
|
43
|
-
return this;
|
44
|
-
}
|
45
|
-
|
46
|
-
clearOrderBy() {
|
47
|
-
return this;
|
48
|
-
}
|
49
|
-
|
50
|
-
clearOffset() {
|
51
|
-
return this;
|
52
|
-
}
|
53
|
-
|
54
|
-
clearLimit() {
|
55
|
-
return this;
|
56
|
-
}
|
57
|
-
|
58
|
-
}
|
59
|
-
|
60
|
-
export {Query};
|
1
|
+
class Query {
|
2
|
+
|
3
|
+
where(...whereClauses) {
|
4
|
+
return this;
|
5
|
+
}
|
6
|
+
|
7
|
+
groupBy(...groupByClauses) {
|
8
|
+
return this;
|
9
|
+
}
|
10
|
+
|
11
|
+
orderBy(...orderByClauses) {
|
12
|
+
return this;
|
13
|
+
}
|
14
|
+
|
15
|
+
offset(limitOffset) {
|
16
|
+
return this;
|
17
|
+
}
|
18
|
+
|
19
|
+
limit(numberOfRows) {
|
20
|
+
return this;
|
21
|
+
}
|
22
|
+
|
23
|
+
getWhere() {
|
24
|
+
}
|
25
|
+
|
26
|
+
getGroupBy() {
|
27
|
+
}
|
28
|
+
|
29
|
+
getOrderBy() {
|
30
|
+
}
|
31
|
+
|
32
|
+
getOffset() {
|
33
|
+
}
|
34
|
+
|
35
|
+
getLimit() {
|
36
|
+
}
|
37
|
+
|
38
|
+
clearWhere() {
|
39
|
+
return this;
|
40
|
+
}
|
41
|
+
|
42
|
+
clearGroupBy() {
|
43
|
+
return this;
|
44
|
+
}
|
45
|
+
|
46
|
+
clearOrderBy() {
|
47
|
+
return this;
|
48
|
+
}
|
49
|
+
|
50
|
+
clearOffset() {
|
51
|
+
return this;
|
52
|
+
}
|
53
|
+
|
54
|
+
clearLimit() {
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
export {Query};
|