@scx-js/scx-data 0.2.1 → 0.2.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_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/index.js +8 -9
- 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 +10 -34
- package/query/SkipIfInfo.js +42 -0
- package/query/WhereClause.js +6 -16
- package/serialization/FieldPolicySerializer.js +47 -0
- package/serialization/QuerySerializer.js +120 -0
- package/field_policy/serializer/FieldPolicySerializer.js +0 -30
- 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/QuerySerializer.js +0 -35
- package/query/serializer/WhereSerializer.js +0 -100
@@ -0,0 +1,39 @@
|
|
1
|
+
import {FieldPolicyLike} from "./FieldPolicyLike.js";
|
2
|
+
import {FieldPolicyImpl} from "./FieldPolicyImpl.js";
|
3
|
+
import {EXCLUDED} from "./FilterMode.js";
|
4
|
+
|
5
|
+
class AssignField extends FieldPolicyLike {
|
6
|
+
|
7
|
+
#fieldName;
|
8
|
+
#expression;
|
9
|
+
|
10
|
+
constructor(fieldName, expression) {
|
11
|
+
super();
|
12
|
+
if (fieldName == null) {
|
13
|
+
throw new Error("fieldName is null");
|
14
|
+
}
|
15
|
+
if (expression == null) {
|
16
|
+
throw new Error("expression is null");
|
17
|
+
}
|
18
|
+
this.#fieldName = fieldName;
|
19
|
+
this.#expression = expression;
|
20
|
+
}
|
21
|
+
|
22
|
+
fieldName() {
|
23
|
+
return this.#fieldName;
|
24
|
+
}
|
25
|
+
|
26
|
+
expression() {
|
27
|
+
return this.#expression;
|
28
|
+
}
|
29
|
+
|
30
|
+
toFieldPolicy() {
|
31
|
+
//排除 0个 就是包含所有
|
32
|
+
return new FieldPolicyImpl(EXCLUDED).assignFields(this);
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
export {
|
38
|
+
AssignField,
|
39
|
+
};
|
@@ -8,44 +8,66 @@ class FieldPolicy {
|
|
8
8
|
return this;
|
9
9
|
}
|
10
10
|
|
11
|
-
|
11
|
+
getFilterMode() {
|
12
12
|
}
|
13
13
|
|
14
|
-
|
14
|
+
getFieldNames() {
|
15
15
|
}
|
16
16
|
|
17
17
|
clearFieldNames() {
|
18
|
+
return this;
|
18
19
|
}
|
19
20
|
|
20
|
-
|
21
|
+
virtualFields(...virtualFields) {
|
21
22
|
return this;
|
22
23
|
}
|
23
24
|
|
24
|
-
|
25
|
+
getVirtualFields() {
|
25
26
|
}
|
26
27
|
|
27
|
-
|
28
|
+
clearVirtualFields() {
|
29
|
+
return this;
|
28
30
|
}
|
29
31
|
|
30
|
-
|
32
|
+
virtualField(virtualFieldName, expression) {
|
33
|
+
return this;
|
31
34
|
}
|
32
35
|
|
33
|
-
|
36
|
+
ignoreNull(ignoreNull) {
|
37
|
+
return this;
|
34
38
|
}
|
35
39
|
|
36
|
-
|
40
|
+
ignoreNull_(fieldName, ignoreNull) {
|
41
|
+
return this;
|
42
|
+
}
|
43
|
+
|
44
|
+
assignFields(...assignFields) {
|
45
|
+
return this;
|
46
|
+
}
|
47
|
+
|
48
|
+
getIgnoreNull() {
|
49
|
+
}
|
50
|
+
|
51
|
+
getIgnoreNulls() {
|
37
52
|
}
|
38
53
|
|
39
|
-
|
54
|
+
getAssignFields() {
|
40
55
|
}
|
41
56
|
|
42
|
-
|
57
|
+
clearIgnoreNulls() {
|
58
|
+
return this;
|
43
59
|
}
|
44
60
|
|
45
|
-
|
61
|
+
clearAssignFields() {
|
62
|
+
return this;
|
46
63
|
}
|
47
64
|
|
48
|
-
|
65
|
+
removeIgnoreNull(fieldName) {
|
66
|
+
return this;
|
67
|
+
}
|
68
|
+
|
69
|
+
assignField(fieldName, expression) {
|
70
|
+
return this;
|
49
71
|
}
|
50
72
|
|
51
73
|
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import {FieldPolicyImpl} from "./FieldPolicyImpl.js";
|
2
2
|
import {EXCLUDED, INCLUDED} from "./FilterMode.js";
|
3
|
+
import {AssignField} from "./AssignField.js";
|
4
|
+
import {VirtualField} from "./VirtualField.js";
|
3
5
|
|
4
6
|
function includeAll() {
|
5
7
|
return new FieldPolicyImpl(EXCLUDED);
|
@@ -9,34 +11,31 @@ function excludeAll() {
|
|
9
11
|
return new FieldPolicyImpl(INCLUDED);
|
10
12
|
}
|
11
13
|
|
12
|
-
/**
|
13
|
-
*
|
14
|
-
* @param fieldNames
|
15
|
-
* @return {FieldPolicy}
|
16
|
-
*/
|
17
14
|
function include(...fieldNames) {
|
18
15
|
return excludeAll().include(...fieldNames);
|
19
16
|
}
|
20
17
|
|
21
|
-
/**
|
22
|
-
*
|
23
|
-
* @param fieldNames
|
24
|
-
* @return {FieldPolicy}
|
25
|
-
*/
|
26
18
|
function exclude(...fieldNames) {
|
27
19
|
return includeAll().exclude(...fieldNames);
|
28
20
|
}
|
29
21
|
|
22
|
+
/// 默认包含所有
|
30
23
|
function ignoreNull(ignoreNull) {
|
31
24
|
return includeAll().ignoreNull(ignoreNull);
|
32
25
|
}
|
33
26
|
|
34
|
-
|
35
|
-
|
27
|
+
/// 默认包含所有
|
28
|
+
function ignoreNull_(fieldName, ignoreNull) {
|
29
|
+
return includeAll().ignoreNull_(fieldName, ignoreNull);
|
36
30
|
}
|
37
31
|
|
38
|
-
|
39
|
-
|
32
|
+
/// 默认包含所有
|
33
|
+
function assignField(fieldName, expression) {
|
34
|
+
return new AssignField(fieldName, expression);
|
35
|
+
}
|
36
|
+
|
37
|
+
function virtualField(virtualFieldName, expression) {
|
38
|
+
return new VirtualField(virtualFieldName, expression);
|
40
39
|
}
|
41
40
|
|
42
41
|
export {
|
@@ -45,6 +44,7 @@ export {
|
|
45
44
|
include,
|
46
45
|
exclude,
|
47
46
|
ignoreNull,
|
48
|
-
|
49
|
-
|
47
|
+
ignoreNull_,
|
48
|
+
assignField,
|
49
|
+
virtualField,
|
50
50
|
};
|
@@ -1,46 +1,48 @@
|
|
1
1
|
import {EXCLUDED, INCLUDED} from "./FilterMode.js";
|
2
2
|
import {FieldPolicy} from "./FieldPolicy.js";
|
3
|
+
import {AssignField} from "./AssignField.js";
|
4
|
+
import {VirtualField} from "./VirtualField.js";
|
3
5
|
|
4
6
|
class FieldPolicyImpl extends FieldPolicy {
|
5
7
|
|
6
8
|
#filterMode;
|
7
9
|
#fieldNames;
|
8
|
-
#expressions;
|
9
10
|
#ignoreNulls;
|
11
|
+
#virtualFields;
|
12
|
+
#assignFields;
|
10
13
|
#ignoreNull;
|
11
14
|
|
12
15
|
constructor(filterMode) {
|
13
16
|
super();
|
14
17
|
this.#filterMode = filterMode;
|
15
18
|
this.#fieldNames = new Set();
|
16
|
-
this.#
|
19
|
+
this.#virtualFields = [];
|
20
|
+
this.#assignFields = [];
|
17
21
|
this.#ignoreNulls = new Map();
|
18
22
|
this.#ignoreNull = true;
|
19
23
|
}
|
20
24
|
|
21
25
|
include(...fieldNames) {
|
22
26
|
if (this.#filterMode === INCLUDED) {
|
23
|
-
this.addFieldNames(...fieldNames);
|
27
|
+
return this.addFieldNames(...fieldNames);
|
24
28
|
} else if (this.#filterMode === EXCLUDED) {
|
25
|
-
this.removeFieldNames(...fieldNames);
|
29
|
+
return this.removeFieldNames(...fieldNames);
|
26
30
|
}
|
27
|
-
return this;
|
28
31
|
}
|
29
32
|
|
30
33
|
exclude(...fieldNames) {
|
31
|
-
if (this.#filterMode ===
|
32
|
-
this.
|
33
|
-
} else if (this.#filterMode ===
|
34
|
-
this.
|
34
|
+
if (this.#filterMode === INCLUDED) {
|
35
|
+
return this.removeFieldNames(...fieldNames);
|
36
|
+
} else if (this.#filterMode === EXCLUDED) {
|
37
|
+
return this.addFieldNames(...fieldNames);
|
35
38
|
}
|
36
|
-
return this;
|
37
39
|
}
|
38
40
|
|
39
|
-
|
41
|
+
getFilterMode() {
|
40
42
|
return this.#filterMode;
|
41
43
|
}
|
42
44
|
|
43
|
-
|
45
|
+
getFieldNames() {
|
44
46
|
return Array.from(this.#fieldNames);
|
45
47
|
}
|
46
48
|
|
@@ -49,64 +51,83 @@ class FieldPolicyImpl extends FieldPolicy {
|
|
49
51
|
return this;
|
50
52
|
}
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
+
addFieldNames(...fieldNames) {
|
55
|
+
for (const name of fieldNames) {
|
56
|
+
this.#fieldNames.add(name);
|
57
|
+
}
|
54
58
|
return this;
|
55
59
|
}
|
56
60
|
|
57
|
-
|
58
|
-
|
61
|
+
removeFieldNames(...fieldNames) {
|
62
|
+
for (const name of fieldNames) {
|
63
|
+
this.#fieldNames.delete(name);
|
64
|
+
}
|
65
|
+
return this;
|
59
66
|
}
|
60
67
|
|
61
|
-
|
62
|
-
this.#
|
68
|
+
virtualFields(...virtualFields) {
|
69
|
+
this.#virtualFields = [...virtualFields];
|
63
70
|
return this;
|
64
71
|
}
|
65
72
|
|
66
|
-
|
67
|
-
this.#
|
73
|
+
getVirtualFields() {
|
74
|
+
return this.#virtualFields;
|
75
|
+
}
|
76
|
+
|
77
|
+
clearVirtualFields() {
|
78
|
+
this.#virtualFields = [];
|
68
79
|
return this;
|
69
80
|
}
|
70
81
|
|
71
|
-
|
72
|
-
|
82
|
+
virtualField(name, expression) {
|
83
|
+
this.#virtualFields.push(new VirtualField(name, expression));
|
84
|
+
return this;
|
73
85
|
}
|
74
86
|
|
75
|
-
|
76
|
-
this.#
|
87
|
+
ignoreNull(ignoreNull) {
|
88
|
+
this.#ignoreNull = ignoreNull;
|
77
89
|
return this;
|
78
90
|
}
|
79
91
|
|
80
|
-
|
81
|
-
this.#
|
92
|
+
ignoreNull_(fieldName, ignoreNull) {
|
93
|
+
this.#ignoreNulls.set(fieldName, ignoreNull);
|
82
94
|
return this;
|
83
95
|
}
|
84
96
|
|
85
|
-
|
86
|
-
|
97
|
+
assignFields(...assignFields) {
|
98
|
+
this.#assignFields = [...assignFields];
|
99
|
+
return this;
|
100
|
+
}
|
101
|
+
|
102
|
+
getIgnoreNull() {
|
103
|
+
return this.#ignoreNull;
|
104
|
+
}
|
105
|
+
|
106
|
+
getIgnoreNulls() {
|
107
|
+
return Object.fromEntries(this.#ignoreNulls);
|
108
|
+
}
|
109
|
+
|
110
|
+
getAssignFields() {
|
111
|
+
return this.#assignFields;
|
87
112
|
}
|
88
113
|
|
89
|
-
|
90
|
-
this.#
|
114
|
+
clearIgnoreNulls() {
|
115
|
+
this.#ignoreNulls.clear();
|
91
116
|
return this;
|
92
117
|
}
|
93
118
|
|
94
|
-
|
95
|
-
this.#
|
119
|
+
clearAssignFields() {
|
120
|
+
this.#assignFields = [];
|
96
121
|
return this;
|
97
122
|
}
|
98
123
|
|
99
|
-
|
100
|
-
|
101
|
-
this.#fieldNames.add(fieldName);
|
102
|
-
}
|
124
|
+
removeIgnoreNull(fieldName) {
|
125
|
+
this.#ignoreNulls.delete(fieldName);
|
103
126
|
return this;
|
104
127
|
}
|
105
128
|
|
106
|
-
|
107
|
-
|
108
|
-
this.#fieldNames.delete(fieldName);
|
109
|
-
}
|
129
|
+
assignField(fieldName, expression) {
|
130
|
+
this.#assignFields.push(new AssignField(fieldName, expression));
|
110
131
|
return this;
|
111
132
|
}
|
112
133
|
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import {FieldPolicy} from "./FieldPolicy.js";
|
2
|
+
|
3
|
+
class FieldPolicyLike extends FieldPolicy {
|
4
|
+
|
5
|
+
#fieldPolicy;
|
6
|
+
|
7
|
+
fieldPolicy() {
|
8
|
+
if (this.#fieldPolicy == null) {
|
9
|
+
this.#fieldPolicy = this.toFieldPolicy();
|
10
|
+
}
|
11
|
+
return this.#fieldPolicy;
|
12
|
+
}
|
13
|
+
|
14
|
+
include(...fieldNames) {
|
15
|
+
this.fieldPolicy().include(...fieldNames);
|
16
|
+
return this;
|
17
|
+
}
|
18
|
+
|
19
|
+
exclude(...fieldNames) {
|
20
|
+
this.fieldPolicy().exclude(...fieldNames);
|
21
|
+
return this;
|
22
|
+
}
|
23
|
+
|
24
|
+
getFilterMode() {
|
25
|
+
return this.fieldPolicy().getFilterMode();
|
26
|
+
}
|
27
|
+
|
28
|
+
getFieldNames() {
|
29
|
+
return this.fieldPolicy().getFieldNames();
|
30
|
+
}
|
31
|
+
|
32
|
+
clearFieldNames() {
|
33
|
+
this.fieldPolicy().clearFieldNames();
|
34
|
+
return this;
|
35
|
+
}
|
36
|
+
|
37
|
+
virtualFields(...virtualFields) {
|
38
|
+
this.fieldPolicy().virtualFields(...virtualFields);
|
39
|
+
return this;
|
40
|
+
}
|
41
|
+
|
42
|
+
getVirtualFields() {
|
43
|
+
return this.fieldPolicy().getVirtualFields();
|
44
|
+
}
|
45
|
+
|
46
|
+
clearVirtualFields() {
|
47
|
+
this.fieldPolicy().clearVirtualFields();
|
48
|
+
return this;
|
49
|
+
}
|
50
|
+
|
51
|
+
virtualField(virtualFieldName, expression) {
|
52
|
+
this.fieldPolicy().virtualField(virtualFieldName, expression);
|
53
|
+
return this;
|
54
|
+
}
|
55
|
+
|
56
|
+
ignoreNull(ignoreNull) {
|
57
|
+
this.fieldPolicy().ignoreNull(ignoreNull);
|
58
|
+
return this;
|
59
|
+
}
|
60
|
+
|
61
|
+
ignoreNull_(fieldName, ignoreNull) {
|
62
|
+
this.fieldPolicy().ignoreNull_(fieldName, ignoreNull);
|
63
|
+
return this;
|
64
|
+
}
|
65
|
+
|
66
|
+
assignFields(...assignFields) {
|
67
|
+
this.fieldPolicy().assignFields(...assignFields);
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
|
71
|
+
getIgnoreNull() {
|
72
|
+
return this.fieldPolicy().getIgnoreNull();
|
73
|
+
}
|
74
|
+
|
75
|
+
getIgnoreNulls() {
|
76
|
+
return this.fieldPolicy().getIgnoreNulls();
|
77
|
+
}
|
78
|
+
|
79
|
+
getAssignFields() {
|
80
|
+
return this.fieldPolicy().getAssignFields();
|
81
|
+
}
|
82
|
+
|
83
|
+
clearIgnoreNulls() {
|
84
|
+
this.fieldPolicy().clearIgnoreNulls();
|
85
|
+
return this;
|
86
|
+
}
|
87
|
+
|
88
|
+
clearAssignFields() {
|
89
|
+
this.fieldPolicy().clearAssignFields();
|
90
|
+
return this;
|
91
|
+
}
|
92
|
+
|
93
|
+
removeIgnoreNull(fieldName) {
|
94
|
+
this.fieldPolicy().removeIgnoreNull(fieldName);
|
95
|
+
return this;
|
96
|
+
}
|
97
|
+
|
98
|
+
assignField(fieldName, expression) {
|
99
|
+
this.fieldPolicy().assignField(fieldName, expression);
|
100
|
+
return this;
|
101
|
+
}
|
102
|
+
|
103
|
+
toFieldPolicy() {
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
export {
|
110
|
+
FieldPolicyLike,
|
111
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import {FieldPolicyLike} from "./FieldPolicyLike.js";
|
2
|
+
import {FieldPolicyImpl} from "./FieldPolicyImpl.js";
|
3
|
+
import {EXCLUDED} from "./FilterMode.js";
|
4
|
+
|
5
|
+
class VirtualField extends FieldPolicyLike {
|
6
|
+
|
7
|
+
#virtualFieldName;
|
8
|
+
#expression;
|
9
|
+
|
10
|
+
constructor(virtualFieldName, expression) {
|
11
|
+
super();
|
12
|
+
if (virtualFieldName == null) {
|
13
|
+
throw new Error("virtualFieldName is null");
|
14
|
+
}
|
15
|
+
if (expression == null) {
|
16
|
+
throw new Error("expression is null");
|
17
|
+
}
|
18
|
+
this.#virtualFieldName = virtualFieldName;
|
19
|
+
this.#expression = expression;
|
20
|
+
}
|
21
|
+
|
22
|
+
virtualFieldName() {
|
23
|
+
return this.#virtualFieldName;
|
24
|
+
}
|
25
|
+
|
26
|
+
expression() {
|
27
|
+
return this.#expression;
|
28
|
+
}
|
29
|
+
|
30
|
+
toFieldPolicy() {
|
31
|
+
//排除 0个 就是包含所有
|
32
|
+
return new FieldPolicyImpl(EXCLUDED).virtualFields(this);
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
export {
|
38
|
+
VirtualField,
|
39
|
+
};
|
package/index.js
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
export * from "./field_policy/
|
1
|
+
export * from "./field_policy/AssignField.js";
|
2
2
|
export * from "./field_policy/FieldPolicy.js";
|
3
3
|
export * from "./field_policy/FieldPolicyBuilder.js";
|
4
4
|
export * from "./field_policy/FieldPolicyImpl.js";
|
5
|
+
export * from "./field_policy/FieldPolicyLike.js";
|
5
6
|
export * from "./field_policy/FilterMode.js";
|
6
|
-
export * from "./
|
7
|
-
export * from "./query/serializer/OrderBySerializer.js";
|
8
|
-
export * from "./query/serializer/QuerySerializer.js";
|
9
|
-
export * from "./query/serializer/WhereSerializer.js";
|
10
|
-
export * from "./query/GroupBy.js";
|
7
|
+
export * from "./field_policy/VirtualField.js";
|
11
8
|
export * from "./query/Junction.js";
|
12
9
|
export * from "./query/And.js";
|
13
10
|
export * from "./query/Or.js";
|
@@ -18,7 +15,9 @@ export * from "./query/Query.js";
|
|
18
15
|
export * from "./query/QueryBuilder.js";
|
19
16
|
export * from "./query/QueryImpl.js";
|
20
17
|
export * from "./query/QueryLike.js";
|
21
|
-
export * from "./query/
|
22
|
-
export * from "./query/
|
18
|
+
export * from "./query/BuildControl.js";
|
19
|
+
export * from "./query/Condition.js";
|
23
20
|
export * from "./query/WhereClause.js";
|
24
|
-
export * from "./query/
|
21
|
+
export * from "./query/ConditionType.js";
|
22
|
+
export * from "./serialization/QuerySerializer.js";
|
23
|
+
export * from "./serialization/FieldPolicySerializer.js";
|
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.3",
|
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.3"
|
15
15
|
}
|
16
16
|
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class BuildControl {
|
2
|
+
|
3
|
+
#value;
|
4
|
+
|
5
|
+
constructor(value) {
|
6
|
+
this.#value = value;
|
7
|
+
}
|
8
|
+
|
9
|
+
}
|
10
|
+
|
11
|
+
const SKIP_IF_NULL = new BuildControl("SKIP_IF_NULL");
|
12
|
+
const SKIP_IF_EMPTY_LIST = new BuildControl("SKIP_IF_EMPTY_LIST");
|
13
|
+
const SKIP_IF_EMPTY_STRING = new BuildControl("SKIP_IF_EMPTY_STRING");
|
14
|
+
const SKIP_IF_BLANK_STRING = new BuildControl("SKIP_IF_BLANK_STRING");
|
15
|
+
const USE_EXPRESSION = new BuildControl("USE_EXPRESSION");
|
16
|
+
const USE_EXPRESSION_VALUE = new BuildControl("USE_EXPRESSION_VALUE");
|
17
|
+
|
18
|
+
|
19
|
+
function checkUseExpression(...controls) {
|
20
|
+
for (let control of controls) {
|
21
|
+
if (control === USE_EXPRESSION) {
|
22
|
+
return true;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
|
28
|
+
function checkUseExpressionValue(...controls) {
|
29
|
+
for (let control of controls) {
|
30
|
+
if (control === USE_EXPRESSION_VALUE) {
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
|
37
|
+
export {
|
38
|
+
BuildControl,
|
39
|
+
SKIP_IF_NULL,
|
40
|
+
SKIP_IF_EMPTY_LIST,
|
41
|
+
SKIP_IF_BLANK_STRING,
|
42
|
+
SKIP_IF_EMPTY_STRING,
|
43
|
+
checkUseExpression,
|
44
|
+
checkUseExpressionValue,
|
45
|
+
};
|
@@ -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
|
};
|