@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.
@@ -1,40 +1,40 @@
1
- class FieldFilter {
2
-
3
- addIncluded(...fieldNames) {
4
- return this;
5
- }
6
-
7
- addExcluded(...fieldNames) {
8
- return this;
9
- }
10
-
11
- removeIncluded(...fieldNames) {
12
- return this;
13
- }
14
-
15
- removeExcluded(...fieldNames) {
16
- return this;
17
- }
18
-
19
- ignoreNullValue(ignoreNullValue) {
20
- return this;
21
- }
22
-
23
- getFilterMode() {
24
- }
25
-
26
- getFieldNames() {
27
- }
28
-
29
- getIgnoreNullValue() {
30
- }
31
-
32
- clear() {
33
- return this;
34
- }
35
-
36
- }
37
-
38
- export {
39
- FieldFilter,
40
- };
1
+ class FieldFilter {
2
+
3
+ addIncluded(...fieldNames) {
4
+ return this;
5
+ }
6
+
7
+ addExcluded(...fieldNames) {
8
+ return this;
9
+ }
10
+
11
+ removeIncluded(...fieldNames) {
12
+ return this;
13
+ }
14
+
15
+ removeExcluded(...fieldNames) {
16
+ return this;
17
+ }
18
+
19
+ ignoreNullValue(ignoreNullValue) {
20
+ return this;
21
+ }
22
+
23
+ getFilterMode() {
24
+ }
25
+
26
+ getFieldNames() {
27
+ }
28
+
29
+ getIgnoreNullValue() {
30
+ }
31
+
32
+ clear() {
33
+ return this;
34
+ }
35
+
36
+ }
37
+
38
+ export {
39
+ FieldFilter,
40
+ };
@@ -1,25 +1,25 @@
1
- import {FieldFilterImpl} from "./FieldFilterImpl.js";
2
- import {EXCLUDED, INCLUDED} from "./FilterMode.js";
3
-
4
- /**
5
- *
6
- * @param fieldNames
7
- * @return {FieldFilter}
8
- */
9
- function ofIncluded(...fieldNames) {
10
- return new FieldFilterImpl(INCLUDED).addIncluded(...fieldNames);
11
- }
12
-
13
- /**
14
- *
15
- * @param fieldNames
16
- * @return {FieldFilter}
17
- */
18
- function ofExcluded(...fieldNames) {
19
- return new FieldFilterImpl(EXCLUDED).addExcluded(...fieldNames);
20
- }
21
-
22
- export {
23
- ofIncluded,
24
- ofExcluded,
25
- };
1
+ import {FieldFilterImpl} from "./FieldFilterImpl.js";
2
+ import {EXCLUDED, INCLUDED} from "./FilterMode.js";
3
+
4
+ /**
5
+ *
6
+ * @param fieldNames
7
+ * @return {FieldFilter}
8
+ */
9
+ function ofIncluded(...fieldNames) {
10
+ return new FieldFilterImpl(INCLUDED).addIncluded(...fieldNames);
11
+ }
12
+
13
+ /**
14
+ *
15
+ * @param fieldNames
16
+ * @return {FieldFilter}
17
+ */
18
+ function ofExcluded(...fieldNames) {
19
+ return new FieldFilterImpl(EXCLUDED).addExcluded(...fieldNames);
20
+ }
21
+
22
+ export {
23
+ ofIncluded,
24
+ ofExcluded,
25
+ };
@@ -1,81 +1,81 @@
1
- import {EXCLUDED, INCLUDED} from "./FilterMode.js";
2
- import {FieldFilter} from "./FieldFilter.js";
3
-
4
- class FieldFilterImpl extends FieldFilter {
5
-
6
- #filterMode;
7
- #fieldNames;
8
- #ignoreNullValue;
9
-
10
- constructor(filterMode) {
11
- super();
12
- this.#filterMode = filterMode;
13
- this.#fieldNames = new Set();
14
- this.#ignoreNullValue = true;
15
- }
16
-
17
- addIncluded(...fieldNames) {
18
- if (this.#filterMode === INCLUDED) {
19
- this.addFieldNames(...fieldNames);
20
- } else if (this.#filterMode === EXCLUDED) {
21
- this.removeFieldNames(...fieldNames);
22
- }
23
- return this;
24
- }
25
-
26
- addExcluded(...fieldNames) {
27
- if (this.#filterMode === EXCLUDED) {
28
- this.addFieldNames(...fieldNames);
29
- } else if (this.#filterMode === INCLUDED) {
30
- this.removeFieldNames(...fieldNames);
31
- }
32
- return this;
33
- }
34
-
35
- removeIncluded(...fieldNames) {
36
- return this.addExcluded(...fieldNames);
37
- }
38
-
39
- removeExcluded(...fieldNames) {
40
- return this.addIncluded(...fieldNames);
41
- }
42
-
43
- ignoreNullValue(ignoreNullValue) {
44
- this.#ignoreNullValue = ignoreNullValue;
45
- return this;
46
- }
47
-
48
- getFilterMode() {
49
- return this.#filterMode;
50
- }
51
-
52
- getFieldNames() {
53
- return Array.from(this.#fieldNames);
54
- }
55
-
56
- getIgnoreNullValue() {
57
- return this.#ignoreNullValue;
58
- }
59
-
60
- clear() {
61
- this.#fieldNames.clear();
62
- return this;
63
- }
64
-
65
- addFieldNames(...fieldNames) {
66
- for (let fieldName of fieldNames) {
67
- this.#fieldNames.add(fieldName);
68
- }
69
- return this;
70
- }
71
-
72
- removeFieldNames(...fieldNames) {
73
- for (let fieldName of fieldNames) {
74
- this.#fieldNames.delete(fieldName);
75
- }
76
- return this;
77
- }
78
-
79
- }
80
-
81
- export {FieldFilterImpl};
1
+ import {EXCLUDED, INCLUDED} from "./FilterMode.js";
2
+ import {FieldFilter} from "./FieldFilter.js";
3
+
4
+ class FieldFilterImpl extends FieldFilter {
5
+
6
+ #filterMode;
7
+ #fieldNames;
8
+ #ignoreNullValue;
9
+
10
+ constructor(filterMode) {
11
+ super();
12
+ this.#filterMode = filterMode;
13
+ this.#fieldNames = new Set();
14
+ this.#ignoreNullValue = true;
15
+ }
16
+
17
+ addIncluded(...fieldNames) {
18
+ if (this.#filterMode === INCLUDED) {
19
+ this.addFieldNames(...fieldNames);
20
+ } else if (this.#filterMode === EXCLUDED) {
21
+ this.removeFieldNames(...fieldNames);
22
+ }
23
+ return this;
24
+ }
25
+
26
+ addExcluded(...fieldNames) {
27
+ if (this.#filterMode === EXCLUDED) {
28
+ this.addFieldNames(...fieldNames);
29
+ } else if (this.#filterMode === INCLUDED) {
30
+ this.removeFieldNames(...fieldNames);
31
+ }
32
+ return this;
33
+ }
34
+
35
+ removeIncluded(...fieldNames) {
36
+ return this.addExcluded(...fieldNames);
37
+ }
38
+
39
+ removeExcluded(...fieldNames) {
40
+ return this.addIncluded(...fieldNames);
41
+ }
42
+
43
+ ignoreNullValue(ignoreNullValue) {
44
+ this.#ignoreNullValue = ignoreNullValue;
45
+ return this;
46
+ }
47
+
48
+ getFilterMode() {
49
+ return this.#filterMode;
50
+ }
51
+
52
+ getFieldNames() {
53
+ return Array.from(this.#fieldNames);
54
+ }
55
+
56
+ getIgnoreNullValue() {
57
+ return this.#ignoreNullValue;
58
+ }
59
+
60
+ clear() {
61
+ this.#fieldNames.clear();
62
+ return this;
63
+ }
64
+
65
+ addFieldNames(...fieldNames) {
66
+ for (let fieldName of fieldNames) {
67
+ this.#fieldNames.add(fieldName);
68
+ }
69
+ return this;
70
+ }
71
+
72
+ removeFieldNames(...fieldNames) {
73
+ for (let fieldName of fieldNames) {
74
+ this.#fieldNames.delete(fieldName);
75
+ }
76
+ return this;
77
+ }
78
+
79
+ }
80
+
81
+ export {FieldFilterImpl};
@@ -1,5 +1,5 @@
1
- const INCLUDED = "INCLUDED";
2
-
3
- const EXCLUDED = "EXCLUDED";
4
-
5
- export {INCLUDED, EXCLUDED};
1
+ const INCLUDED = "INCLUDED";
2
+
3
+ const EXCLUDED = "EXCLUDED";
4
+
5
+ export {INCLUDED, EXCLUDED};
@@ -1,28 +1,28 @@
1
- import {FieldFilter} from "../FieldFilter.js";
2
-
3
- class FieldFilterSerializer {
4
-
5
- serialize(obj) {
6
- if (obj instanceof FieldFilter) {
7
- return this.serializeFieldFilter(obj);
8
- }
9
- return obj;
10
- }
11
-
12
- serializeFieldFilter(fieldFilter) {
13
- return {
14
- "@type": "FieldFilter",
15
- "filterMode": fieldFilter.getFilterMode(),
16
- "fieldNames": fieldFilter.getFieldNames(),
17
- "ignoreNullValue": fieldFilter.getIgnoreNullValue(),
18
- };
19
- }
20
-
21
- }
22
-
23
- const FIELD_FILTER_SERIALIZER = new FieldFilterSerializer();
24
-
25
- export {
26
- FIELD_FILTER_SERIALIZER,
27
- FieldFilterSerializer,
28
- };
1
+ import {FieldFilter} from "../FieldFilter.js";
2
+
3
+ class FieldFilterSerializer {
4
+
5
+ serialize(obj) {
6
+ if (obj instanceof FieldFilter) {
7
+ return this.serializeFieldFilter(obj);
8
+ }
9
+ return obj;
10
+ }
11
+
12
+ serializeFieldFilter(fieldFilter) {
13
+ return {
14
+ "@type": "FieldFilter",
15
+ "filterMode": fieldFilter.getFilterMode(),
16
+ "fieldNames": fieldFilter.getFieldNames(),
17
+ "ignoreNullValue": fieldFilter.getIgnoreNullValue(),
18
+ };
19
+ }
20
+
21
+ }
22
+
23
+ const FIELD_FILTER_SERIALIZER = new FieldFilterSerializer();
24
+
25
+ export {
26
+ FIELD_FILTER_SERIALIZER,
27
+ FieldFilterSerializer,
28
+ };
package/index.js CHANGED
@@ -1,6 +1,22 @@
1
- export * from "./field_filter/FieldFilterBuilder.js";
2
- export * from "./field_filter/FilterMode.js";
3
- export * from "./query/GroupBy.js";
4
- export * from "./query/OrderBy.js";
5
- export * from "./query/QueryBuilder.js";
6
- export * from "./query/QueryOption.js";
1
+ export * from "./field_filter/serializer/FieldFilterSerializer.js";
2
+ export * from "./field_filter/FieldFilter.js";
3
+ export * from "./field_filter/FieldFilterBuilder.js";
4
+ export * from "./field_filter/FieldFilterImpl.js";
5
+ export * from "./field_filter/FilterMode.js";
6
+ export * from "./query/serializer/GroupBySerializer.js";
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";
11
+ export * from "./query/Logic.js";
12
+ export * from "./query/LogicType.js";
13
+ export * from "./query/OrderBy.js";
14
+ export * from "./query/OrderByType.js";
15
+ export * from "./query/Query.js";
16
+ export * from "./query/QueryBuilder.js";
17
+ export * from "./query/QueryImpl.js";
18
+ export * from "./query/QueryLike.js";
19
+ export * from "./query/QueryOption.js";
20
+ export * from "./query/Where.js";
21
+ export * from "./query/WhereClause.js";
22
+ export * from "./query/WhereType.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scx-js/scx-data",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "SCX Data",
5
5
  "license": "MIT",
6
6
  "author": "scx567888",
package/query/GroupBy.js CHANGED
@@ -1,36 +1,36 @@
1
- import {isBlank} from "../../scx-common/index.js";
2
- import {QueryImpl} from "./QueryImpl.js";
3
- import {QueryLike} from "./QueryLike.js";
4
- import {ofInfo} from "./QueryOption.js";
5
-
6
- class GroupBy extends QueryLike {
7
-
8
- #name;
9
- #info;
10
-
11
- constructor(name, ...options) {
12
- super();
13
- if (isBlank(name)) {
14
- throw new Error("GroupBy 参数错误 : 名称 不能为空 !!!");
15
- }
16
- this.#name = name;
17
- this.#info = ofInfo(...options);
18
- }
19
-
20
- name() {
21
- return this.#name;
22
- }
23
-
24
- info() {
25
- return this.#info;
26
- }
27
-
28
- toQuery() {
29
- return new QueryImpl().groupBy(this);
30
- }
31
-
32
- }
33
-
34
- export {
35
- GroupBy,
36
- };
1
+ import {isBlank} from "@scx-js/scx-common";
2
+ import {QueryImpl} from "./QueryImpl.js";
3
+ import {QueryLike} from "./QueryLike.js";
4
+ import {ofInfo} from "./QueryOption.js";
5
+
6
+ class GroupBy extends QueryLike {
7
+
8
+ #name;
9
+ #info;
10
+
11
+ constructor(name, ...options) {
12
+ super();
13
+ if (isBlank(name)) {
14
+ throw new Error("GroupBy 参数错误 : 名称 不能为空 !!!");
15
+ }
16
+ this.#name = name;
17
+ this.#info = ofInfo(...options);
18
+ }
19
+
20
+ name() {
21
+ return this.#name;
22
+ }
23
+
24
+ info() {
25
+ return this.#info;
26
+ }
27
+
28
+ toQuery() {
29
+ return new QueryImpl().groupBy(this);
30
+ }
31
+
32
+ }
33
+
34
+ export {
35
+ GroupBy,
36
+ };