@scx-js/scx-data 0.0.1 → 0.0.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_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/QueryLike.js
CHANGED
@@ -1,89 +1,89 @@
|
|
1
|
-
import {Query} from "./Query.js";
|
2
|
-
|
3
|
-
class QueryLike extends Query {
|
4
|
-
|
5
|
-
#query;
|
6
|
-
|
7
|
-
query() {
|
8
|
-
if (this.#query == null) {
|
9
|
-
this.#query = this.toQuery();
|
10
|
-
}
|
11
|
-
return this.#query;
|
12
|
-
}
|
13
|
-
|
14
|
-
where(...whereClauses) {
|
15
|
-
this.query().where(...whereClauses);
|
16
|
-
return this;
|
17
|
-
}
|
18
|
-
|
19
|
-
groupBy(...groupByClauses) {
|
20
|
-
this.query().groupBy(...groupByClauses);
|
21
|
-
return this;
|
22
|
-
}
|
23
|
-
|
24
|
-
orderBy(...orderByClauses) {
|
25
|
-
this.query().orderBy(...orderByClauses);
|
26
|
-
return this;
|
27
|
-
}
|
28
|
-
|
29
|
-
offset(limitOffset) {
|
30
|
-
this.query().offset(limitOffset);
|
31
|
-
return this;
|
32
|
-
}
|
33
|
-
|
34
|
-
limit(numberOfRows) {
|
35
|
-
this.query().limit(numberOfRows);
|
36
|
-
return this;
|
37
|
-
}
|
38
|
-
|
39
|
-
getWhere() {
|
40
|
-
return this.query().getWhere();
|
41
|
-
}
|
42
|
-
|
43
|
-
getGroupBy() {
|
44
|
-
return this.query().getGroupBy();
|
45
|
-
}
|
46
|
-
|
47
|
-
getOrderBy() {
|
48
|
-
return this.query().getOrderBy();
|
49
|
-
}
|
50
|
-
|
51
|
-
getOffset() {
|
52
|
-
return this.query().getOffset();
|
53
|
-
}
|
54
|
-
|
55
|
-
getLimit() {
|
56
|
-
return this.query().getLimit();
|
57
|
-
}
|
58
|
-
|
59
|
-
clearWhere() {
|
60
|
-
this.query().clearWhere();
|
61
|
-
return this;
|
62
|
-
}
|
63
|
-
|
64
|
-
clearGroupBy() {
|
65
|
-
this.query().clearGroupBy();
|
66
|
-
return this;
|
67
|
-
}
|
68
|
-
|
69
|
-
clearOrderBy() {
|
70
|
-
this.query().clearOrderBy();
|
71
|
-
return this;
|
72
|
-
}
|
73
|
-
|
74
|
-
clearOffset() {
|
75
|
-
this.query().clearOffset();
|
76
|
-
return this;
|
77
|
-
}
|
78
|
-
|
79
|
-
clearLimit() {
|
80
|
-
this.query().clearLimit();
|
81
|
-
return this;
|
82
|
-
}
|
83
|
-
|
84
|
-
toQuery() {
|
85
|
-
}
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
export {QueryLike};
|
1
|
+
import {Query} from "./Query.js";
|
2
|
+
|
3
|
+
class QueryLike extends Query {
|
4
|
+
|
5
|
+
#query;
|
6
|
+
|
7
|
+
query() {
|
8
|
+
if (this.#query == null) {
|
9
|
+
this.#query = this.toQuery();
|
10
|
+
}
|
11
|
+
return this.#query;
|
12
|
+
}
|
13
|
+
|
14
|
+
where(...whereClauses) {
|
15
|
+
this.query().where(...whereClauses);
|
16
|
+
return this;
|
17
|
+
}
|
18
|
+
|
19
|
+
groupBy(...groupByClauses) {
|
20
|
+
this.query().groupBy(...groupByClauses);
|
21
|
+
return this;
|
22
|
+
}
|
23
|
+
|
24
|
+
orderBy(...orderByClauses) {
|
25
|
+
this.query().orderBy(...orderByClauses);
|
26
|
+
return this;
|
27
|
+
}
|
28
|
+
|
29
|
+
offset(limitOffset) {
|
30
|
+
this.query().offset(limitOffset);
|
31
|
+
return this;
|
32
|
+
}
|
33
|
+
|
34
|
+
limit(numberOfRows) {
|
35
|
+
this.query().limit(numberOfRows);
|
36
|
+
return this;
|
37
|
+
}
|
38
|
+
|
39
|
+
getWhere() {
|
40
|
+
return this.query().getWhere();
|
41
|
+
}
|
42
|
+
|
43
|
+
getGroupBy() {
|
44
|
+
return this.query().getGroupBy();
|
45
|
+
}
|
46
|
+
|
47
|
+
getOrderBy() {
|
48
|
+
return this.query().getOrderBy();
|
49
|
+
}
|
50
|
+
|
51
|
+
getOffset() {
|
52
|
+
return this.query().getOffset();
|
53
|
+
}
|
54
|
+
|
55
|
+
getLimit() {
|
56
|
+
return this.query().getLimit();
|
57
|
+
}
|
58
|
+
|
59
|
+
clearWhere() {
|
60
|
+
this.query().clearWhere();
|
61
|
+
return this;
|
62
|
+
}
|
63
|
+
|
64
|
+
clearGroupBy() {
|
65
|
+
this.query().clearGroupBy();
|
66
|
+
return this;
|
67
|
+
}
|
68
|
+
|
69
|
+
clearOrderBy() {
|
70
|
+
this.query().clearOrderBy();
|
71
|
+
return this;
|
72
|
+
}
|
73
|
+
|
74
|
+
clearOffset() {
|
75
|
+
this.query().clearOffset();
|
76
|
+
return this;
|
77
|
+
}
|
78
|
+
|
79
|
+
clearLimit() {
|
80
|
+
this.query().clearLimit();
|
81
|
+
return this;
|
82
|
+
}
|
83
|
+
|
84
|
+
toQuery() {
|
85
|
+
}
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
export {QueryLike};
|
package/query/QueryOption.js
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
class QueryOption {
|
2
|
-
|
3
|
-
#value;
|
4
|
-
|
5
|
-
constructor(value) {
|
6
|
-
this.#value = value;
|
7
|
-
}
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
|
12
|
-
const REPLACE = new QueryOption("REPLACE");
|
13
|
-
const SKIP_IF_NULL = new QueryOption("SKIP_IF_NULL");
|
14
|
-
const SKIP_IF_EMPTY_LIST = new QueryOption("SKIP_IF_EMPTY_LIST");
|
15
|
-
const USE_ORIGINAL_NAME = new QueryOption("USE_ORIGINAL_NAME");
|
16
|
-
const USE_JSON_EXTRACT = new QueryOption("USE_JSON_EXTRACT");
|
17
|
-
const USE_ORIGINAL_VALUE = new QueryOption("USE_ORIGINAL_VALUE");
|
18
|
-
|
19
|
-
function ofInfo(...queryOptions) {
|
20
|
-
let replace = false;
|
21
|
-
let skipIfNull = false;
|
22
|
-
let skipIfEmptyList = false;
|
23
|
-
let useOriginalName = false;
|
24
|
-
let useJsonExtract = false;
|
25
|
-
let useOriginalValue = false;
|
26
|
-
for (let option of queryOptions) {
|
27
|
-
if (option === REPLACE) {
|
28
|
-
replace = true;
|
29
|
-
} else if (option === SKIP_IF_NULL) {
|
30
|
-
skipIfNull = true;
|
31
|
-
} else if (option === SKIP_IF_EMPTY_LIST) {
|
32
|
-
skipIfEmptyList = true;
|
33
|
-
} else if (option === USE_ORIGINAL_NAME) {
|
34
|
-
useOriginalName = true;
|
35
|
-
} else if (option === USE_JSON_EXTRACT) {
|
36
|
-
useJsonExtract = true;
|
37
|
-
} else if (option === USE_ORIGINAL_VALUE) {
|
38
|
-
useOriginalValue = true;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return new Info(replace, skipIfNull, skipIfEmptyList, useOriginalName, useJsonExtract, useOriginalValue);
|
42
|
-
}
|
43
|
-
|
44
|
-
class Info {
|
45
|
-
replace;
|
46
|
-
skipIfNull;
|
47
|
-
skipIfEmptyList;
|
48
|
-
useOriginalName;
|
49
|
-
useJsonExtract;
|
50
|
-
useOriginalValue;
|
51
|
-
|
52
|
-
|
53
|
-
constructor(replace, skipIfNull, skipIfEmptyList, useOriginalName, useJsonExtract, useOriginalValue) {
|
54
|
-
this.replace = replace;
|
55
|
-
this.skipIfNull = skipIfNull;
|
56
|
-
this.skipIfEmptyList = skipIfEmptyList;
|
57
|
-
this.useOriginalName = useOriginalName;
|
58
|
-
this.useJsonExtract = useJsonExtract;
|
59
|
-
this.useOriginalValue = useOriginalValue;
|
60
|
-
}
|
61
|
-
|
62
|
-
}
|
63
|
-
|
64
|
-
export {
|
65
|
-
QueryOption,
|
66
|
-
REPLACE,
|
67
|
-
SKIP_IF_NULL,
|
68
|
-
SKIP_IF_EMPTY_LIST,
|
69
|
-
USE_ORIGINAL_NAME,
|
70
|
-
USE_JSON_EXTRACT,
|
71
|
-
USE_ORIGINAL_VALUE,
|
72
|
-
Info,
|
73
|
-
ofInfo,
|
74
|
-
};
|
1
|
+
class QueryOption {
|
2
|
+
|
3
|
+
#value;
|
4
|
+
|
5
|
+
constructor(value) {
|
6
|
+
this.#value = value;
|
7
|
+
}
|
8
|
+
|
9
|
+
|
10
|
+
}
|
11
|
+
|
12
|
+
const REPLACE = new QueryOption("REPLACE");
|
13
|
+
const SKIP_IF_NULL = new QueryOption("SKIP_IF_NULL");
|
14
|
+
const SKIP_IF_EMPTY_LIST = new QueryOption("SKIP_IF_EMPTY_LIST");
|
15
|
+
const USE_ORIGINAL_NAME = new QueryOption("USE_ORIGINAL_NAME");
|
16
|
+
const USE_JSON_EXTRACT = new QueryOption("USE_JSON_EXTRACT");
|
17
|
+
const USE_ORIGINAL_VALUE = new QueryOption("USE_ORIGINAL_VALUE");
|
18
|
+
|
19
|
+
function ofInfo(...queryOptions) {
|
20
|
+
let replace = false;
|
21
|
+
let skipIfNull = false;
|
22
|
+
let skipIfEmptyList = false;
|
23
|
+
let useOriginalName = false;
|
24
|
+
let useJsonExtract = false;
|
25
|
+
let useOriginalValue = false;
|
26
|
+
for (let option of queryOptions) {
|
27
|
+
if (option === REPLACE) {
|
28
|
+
replace = true;
|
29
|
+
} else if (option === SKIP_IF_NULL) {
|
30
|
+
skipIfNull = true;
|
31
|
+
} else if (option === SKIP_IF_EMPTY_LIST) {
|
32
|
+
skipIfEmptyList = true;
|
33
|
+
} else if (option === USE_ORIGINAL_NAME) {
|
34
|
+
useOriginalName = true;
|
35
|
+
} else if (option === USE_JSON_EXTRACT) {
|
36
|
+
useJsonExtract = true;
|
37
|
+
} else if (option === USE_ORIGINAL_VALUE) {
|
38
|
+
useOriginalValue = true;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return new Info(replace, skipIfNull, skipIfEmptyList, useOriginalName, useJsonExtract, useOriginalValue);
|
42
|
+
}
|
43
|
+
|
44
|
+
class Info {
|
45
|
+
replace;
|
46
|
+
skipIfNull;
|
47
|
+
skipIfEmptyList;
|
48
|
+
useOriginalName;
|
49
|
+
useJsonExtract;
|
50
|
+
useOriginalValue;
|
51
|
+
|
52
|
+
|
53
|
+
constructor(replace, skipIfNull, skipIfEmptyList, useOriginalName, useJsonExtract, useOriginalValue) {
|
54
|
+
this.replace = replace;
|
55
|
+
this.skipIfNull = skipIfNull;
|
56
|
+
this.skipIfEmptyList = skipIfEmptyList;
|
57
|
+
this.useOriginalName = useOriginalName;
|
58
|
+
this.useJsonExtract = useJsonExtract;
|
59
|
+
this.useOriginalValue = useOriginalValue;
|
60
|
+
}
|
61
|
+
|
62
|
+
}
|
63
|
+
|
64
|
+
export {
|
65
|
+
QueryOption,
|
66
|
+
REPLACE,
|
67
|
+
SKIP_IF_NULL,
|
68
|
+
SKIP_IF_EMPTY_LIST,
|
69
|
+
USE_ORIGINAL_NAME,
|
70
|
+
USE_JSON_EXTRACT,
|
71
|
+
USE_ORIGINAL_VALUE,
|
72
|
+
Info,
|
73
|
+
ofInfo,
|
74
|
+
};
|
package/query/Where.js
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
import {QueryLike} from "./QueryLike.js";
|
2
|
-
import {isBlank} from "
|
3
|
-
import {QueryImpl} from "./QueryImpl.js";
|
4
|
-
import {ofInfo} from "./QueryOption.js";
|
5
|
-
|
6
|
-
class Where extends QueryLike {
|
7
|
-
|
8
|
-
#name;
|
9
|
-
#whereType;
|
10
|
-
#value1;
|
11
|
-
#value2;
|
12
|
-
#info;
|
13
|
-
|
14
|
-
constructor(name, whereType, value1, value2, ...options) {
|
15
|
-
super();
|
16
|
-
//名称不能为空
|
17
|
-
if (isBlank(name)) {
|
18
|
-
throw new Error("Where 参数错误 : 名称 不能为空 !!!");
|
19
|
-
}
|
20
|
-
//类型也不能为空
|
21
|
-
if (whereType == null) {
|
22
|
-
throw new Error("Where 参数错误 : whereType 不能为空 !!!");
|
23
|
-
}
|
24
|
-
this.#name = name;
|
25
|
-
this.#whereType = whereType;
|
26
|
-
this.#value1 = value1;
|
27
|
-
this.#value2 = value2;
|
28
|
-
this.#info = ofInfo(...options);
|
29
|
-
}
|
30
|
-
|
31
|
-
name() {
|
32
|
-
return this.#name;
|
33
|
-
}
|
34
|
-
|
35
|
-
whereType() {
|
36
|
-
return this.#whereType;
|
37
|
-
}
|
38
|
-
|
39
|
-
value1() {
|
40
|
-
return this.#value1;
|
41
|
-
}
|
42
|
-
|
43
|
-
value2() {
|
44
|
-
return this.#value2;
|
45
|
-
}
|
46
|
-
|
47
|
-
info() {
|
48
|
-
return this.#info;
|
49
|
-
}
|
50
|
-
|
51
|
-
toQuery() {
|
52
|
-
return new QueryImpl().where(this);
|
53
|
-
}
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
export {
|
58
|
-
Where,
|
59
|
-
};
|
1
|
+
import {QueryLike} from "./QueryLike.js";
|
2
|
+
import {isBlank} from "@scx-js/scx-common";
|
3
|
+
import {QueryImpl} from "./QueryImpl.js";
|
4
|
+
import {ofInfo} from "./QueryOption.js";
|
5
|
+
|
6
|
+
class Where extends QueryLike {
|
7
|
+
|
8
|
+
#name;
|
9
|
+
#whereType;
|
10
|
+
#value1;
|
11
|
+
#value2;
|
12
|
+
#info;
|
13
|
+
|
14
|
+
constructor(name, whereType, value1, value2, ...options) {
|
15
|
+
super();
|
16
|
+
//名称不能为空
|
17
|
+
if (isBlank(name)) {
|
18
|
+
throw new Error("Where 参数错误 : 名称 不能为空 !!!");
|
19
|
+
}
|
20
|
+
//类型也不能为空
|
21
|
+
if (whereType == null) {
|
22
|
+
throw new Error("Where 参数错误 : whereType 不能为空 !!!");
|
23
|
+
}
|
24
|
+
this.#name = name;
|
25
|
+
this.#whereType = whereType;
|
26
|
+
this.#value1 = value1;
|
27
|
+
this.#value2 = value2;
|
28
|
+
this.#info = ofInfo(...options);
|
29
|
+
}
|
30
|
+
|
31
|
+
name() {
|
32
|
+
return this.#name;
|
33
|
+
}
|
34
|
+
|
35
|
+
whereType() {
|
36
|
+
return this.#whereType;
|
37
|
+
}
|
38
|
+
|
39
|
+
value1() {
|
40
|
+
return this.#value1;
|
41
|
+
}
|
42
|
+
|
43
|
+
value2() {
|
44
|
+
return this.#value2;
|
45
|
+
}
|
46
|
+
|
47
|
+
info() {
|
48
|
+
return this.#info;
|
49
|
+
}
|
50
|
+
|
51
|
+
toQuery() {
|
52
|
+
return new QueryImpl().where(this);
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
export {
|
58
|
+
Where,
|
59
|
+
};
|
package/query/WhereClause.js
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
import {QueryLike} from "./QueryLike.js";
|
2
|
-
import {QueryImpl} from "./QueryImpl.js";
|
3
|
-
|
4
|
-
class WhereClause extends QueryLike {
|
5
|
-
|
6
|
-
#whereClause;
|
7
|
-
#params;
|
8
|
-
|
9
|
-
constructor(whereClause, params) {
|
10
|
-
super();
|
11
|
-
this.#whereClause = whereClause;
|
12
|
-
this.#params = params;
|
13
|
-
}
|
14
|
-
|
15
|
-
/**
|
16
|
-
* 拼接
|
17
|
-
*
|
18
|
-
* @param other a
|
19
|
-
* @return WhereClause
|
20
|
-
*/
|
21
|
-
concat(other) {
|
22
|
-
return new WhereClause(this.#whereClause.concat(other.#whereClause), this.#params.concat(other.params));
|
23
|
-
}
|
24
|
-
|
25
|
-
isEmpty() {
|
26
|
-
return (this.#whereClause == null || this.#whereClause.isEmpty()) && (this.#params == null || this.#params.length === 0);
|
27
|
-
}
|
28
|
-
|
29
|
-
whereClause() {
|
30
|
-
return this.#whereClause;
|
31
|
-
}
|
32
|
-
|
33
|
-
params() {
|
34
|
-
return this.#params;
|
35
|
-
}
|
36
|
-
|
37
|
-
toQuery() {
|
38
|
-
return new QueryImpl().where(this);
|
39
|
-
}
|
40
|
-
|
41
|
-
}
|
42
|
-
|
43
|
-
export {WhereClause};
|
1
|
+
import {QueryLike} from "./QueryLike.js";
|
2
|
+
import {QueryImpl} from "./QueryImpl.js";
|
3
|
+
|
4
|
+
class WhereClause extends QueryLike {
|
5
|
+
|
6
|
+
#whereClause;
|
7
|
+
#params;
|
8
|
+
|
9
|
+
constructor(whereClause, params) {
|
10
|
+
super();
|
11
|
+
this.#whereClause = whereClause;
|
12
|
+
this.#params = params;
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* 拼接
|
17
|
+
*
|
18
|
+
* @param other a
|
19
|
+
* @return WhereClause
|
20
|
+
*/
|
21
|
+
concat(other) {
|
22
|
+
return new WhereClause(this.#whereClause.concat(other.#whereClause), this.#params.concat(other.params));
|
23
|
+
}
|
24
|
+
|
25
|
+
isEmpty() {
|
26
|
+
return (this.#whereClause == null || this.#whereClause.isEmpty()) && (this.#params == null || this.#params.length === 0);
|
27
|
+
}
|
28
|
+
|
29
|
+
whereClause() {
|
30
|
+
return this.#whereClause;
|
31
|
+
}
|
32
|
+
|
33
|
+
params() {
|
34
|
+
return this.#params;
|
35
|
+
}
|
36
|
+
|
37
|
+
toQuery() {
|
38
|
+
return new QueryImpl().where(this);
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
export {WhereClause};
|