@scx-js/scx-data 0.1.0 → 0.1.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/package.json +2 -2
- package/query/Query.js +24 -0
- package/query/QueryImpl.js +25 -9
- package/query/QueryLike.js +30 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@scx-js/scx-data",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.2",
|
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.1.
|
14
|
+
"@scx-js/scx-common": "0.1.2"
|
15
15
|
}
|
16
16
|
}
|
package/query/Query.js
CHANGED
@@ -55,6 +55,30 @@ class Query {
|
|
55
55
|
return this;
|
56
56
|
}
|
57
57
|
|
58
|
+
addWhere(... whereClauses){
|
59
|
+
return this;
|
60
|
+
}
|
61
|
+
|
62
|
+
addGroupBy(... groupByClauses){
|
63
|
+
return this;
|
64
|
+
}
|
65
|
+
|
66
|
+
addOrderBy(... orderByClauses){
|
67
|
+
return this;
|
68
|
+
}
|
69
|
+
|
70
|
+
removeWhereIf(filter){
|
71
|
+
return this;
|
72
|
+
}
|
73
|
+
|
74
|
+
removeGroupByIf(filter){
|
75
|
+
return this;
|
76
|
+
}
|
77
|
+
|
78
|
+
removeOrderByIf(filter){
|
79
|
+
return this;
|
80
|
+
}
|
81
|
+
|
58
82
|
}
|
59
83
|
|
60
84
|
export {Query};
|
package/query/QueryImpl.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import {Query} from "./Query.js";
|
2
|
+
import {removeIf} from "@scx-js/scx-common"
|
2
3
|
|
3
4
|
class QueryImpl extends Query {
|
4
5
|
|
@@ -23,20 +24,20 @@ class QueryImpl extends Query {
|
|
23
24
|
|
24
25
|
where(...whereClauses) {
|
25
26
|
this.clearWhere();
|
26
|
-
this
|
27
|
+
this.addWhere(...whereClauses);
|
27
28
|
return this;
|
28
29
|
}
|
29
30
|
|
30
31
|
groupBy(...groupByClauses) {
|
31
32
|
this.clearGroupBy();
|
32
|
-
this
|
33
|
+
this.addGroupBy(...groupByClauses);
|
33
34
|
return this;
|
34
35
|
}
|
35
36
|
|
36
37
|
|
37
38
|
orderBy(...orderByClauses) {
|
38
39
|
this.clearOrderBy();
|
39
|
-
this
|
40
|
+
this.addOrderBy(...orderByClauses);
|
40
41
|
return this;
|
41
42
|
}
|
42
43
|
|
@@ -96,13 +97,13 @@ class QueryImpl extends Query {
|
|
96
97
|
return this;
|
97
98
|
}
|
98
99
|
|
99
|
-
|
100
|
+
addWhere(...whereClauses) {
|
100
101
|
for (let whereClause of whereClauses) {
|
101
102
|
if (whereClause == null) {
|
102
103
|
continue;
|
103
104
|
}
|
104
105
|
if (Array.isArray(whereClause)) {
|
105
|
-
this
|
106
|
+
this.addWhere(...whereClause);
|
106
107
|
continue;
|
107
108
|
}
|
108
109
|
this.#where.push(whereClause);
|
@@ -110,13 +111,13 @@ class QueryImpl extends Query {
|
|
110
111
|
return this;
|
111
112
|
}
|
112
113
|
|
113
|
-
|
114
|
+
addGroupBy(...groupByClauses) {
|
114
115
|
for (let groupByClause of groupByClauses) {
|
115
116
|
if (groupByClause == null) {
|
116
117
|
continue;
|
117
118
|
}
|
118
119
|
if (Array.isArray(groupByClause)) {
|
119
|
-
this
|
120
|
+
this.addGroupBy(...groupByClause);
|
120
121
|
continue;
|
121
122
|
}
|
122
123
|
this.#groupBy.push(groupByClause);
|
@@ -124,13 +125,13 @@ class QueryImpl extends Query {
|
|
124
125
|
return this;
|
125
126
|
}
|
126
127
|
|
127
|
-
|
128
|
+
addOrderBy(...orderByClauses) {
|
128
129
|
for (let orderByClause of orderByClauses) {
|
129
130
|
if (orderByClause == null) {
|
130
131
|
continue;
|
131
132
|
}
|
132
133
|
if (Array.isArray(orderByClause)) {
|
133
|
-
this
|
134
|
+
this.addOrderBy(...orderByClause);
|
134
135
|
continue;
|
135
136
|
}
|
136
137
|
this.#orderBy.push(orderByClause);
|
@@ -138,6 +139,21 @@ class QueryImpl extends Query {
|
|
138
139
|
return this;
|
139
140
|
}
|
140
141
|
|
142
|
+
removeWhereIf(filter) {
|
143
|
+
removeIf(this.#where, filter);
|
144
|
+
return this;
|
145
|
+
}
|
146
|
+
|
147
|
+
removeGroupByIf(filter) {
|
148
|
+
removeIf(this.#groupBy, filter);
|
149
|
+
return this;
|
150
|
+
}
|
151
|
+
|
152
|
+
removeOrderByIf(filter) {
|
153
|
+
removeIf(this.#orderBy, filter);
|
154
|
+
return this;
|
155
|
+
}
|
156
|
+
|
141
157
|
}
|
142
158
|
|
143
159
|
export {QueryImpl};
|
package/query/QueryLike.js
CHANGED
@@ -81,6 +81,36 @@ class QueryLike extends Query {
|
|
81
81
|
return this;
|
82
82
|
}
|
83
83
|
|
84
|
+
addWhere(...whereClauses) {
|
85
|
+
this.query().addWhere(whereClauses);
|
86
|
+
return this;
|
87
|
+
}
|
88
|
+
|
89
|
+
addGroupBy(...groupByClauses) {
|
90
|
+
this.query().addGroupBy(groupByClauses);
|
91
|
+
return this;
|
92
|
+
}
|
93
|
+
|
94
|
+
addOrderBy(...orderByClauses) {
|
95
|
+
this.query().addOrderBy(orderByClauses);
|
96
|
+
return this;
|
97
|
+
}
|
98
|
+
|
99
|
+
removeWhereIf(filter) {
|
100
|
+
this.query().removeWhereIf(filter);
|
101
|
+
return this;
|
102
|
+
}
|
103
|
+
|
104
|
+
removeGroupByIf(filter) {
|
105
|
+
this.query().removeGroupByIf(filter);
|
106
|
+
return this;
|
107
|
+
}
|
108
|
+
|
109
|
+
removeOrderByIf(filter) {
|
110
|
+
this.query().removeOrderByIf(filter);
|
111
|
+
return this;
|
112
|
+
}
|
113
|
+
|
84
114
|
toQuery() {
|
85
115
|
}
|
86
116
|
|