@dascompany/database 4.2.3 → 4.2.4
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/dist/query/QueryOptions.d.ts +0 -2
- package/dist/query/QueryOptions.js +1 -15
- package/dist/query/QueryParams.js +3 -2
- package/dist/types/ConnectorE.d.ts +0 -2
- package/dist/types/ConnectorE.js +0 -10
- package/package.json +1 -1
- package/dist/types/QueryOptionsConfig.d.ts +0 -13
- package/dist/types/QueryOptionsConfig.js +0 -1
|
@@ -3,13 +3,11 @@ import OrderByI from "../types/OrderByI";
|
|
|
3
3
|
import WhereOptionI from "../types/WhereOptionI";
|
|
4
4
|
import ParameterI from "../types/ParameterI";
|
|
5
5
|
import ConnectorE from "../types/ConnectorE";
|
|
6
|
-
import QueryOptionsI from "../types/QueryOptionsI";
|
|
7
6
|
export default class QueryOptions {
|
|
8
7
|
private where;
|
|
9
8
|
private orderBy;
|
|
10
9
|
private limit;
|
|
11
10
|
constructor();
|
|
12
|
-
static create(data: QueryOptionsI): QueryOptions;
|
|
13
11
|
getWhere(): WhereOptionI | null;
|
|
14
12
|
getOrderBy(): OrderByI[] | null;
|
|
15
13
|
getLimit(): ResultLimitationI | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ConnectorE
|
|
1
|
+
import ConnectorE from "../types/ConnectorE";
|
|
2
2
|
export default class QueryOptions {
|
|
3
3
|
where;
|
|
4
4
|
orderBy;
|
|
@@ -8,20 +8,6 @@ export default class QueryOptions {
|
|
|
8
8
|
this.orderBy = null;
|
|
9
9
|
this.limit = null;
|
|
10
10
|
}
|
|
11
|
-
static create(data) {
|
|
12
|
-
const queryOptions = new QueryOptions();
|
|
13
|
-
if (data.where) {
|
|
14
|
-
const connector = data.where.connector ? getFromValue(data.where.connector) : ConnectorE.and;
|
|
15
|
-
queryOptions.setWhere(data.where.parameters, connector);
|
|
16
|
-
}
|
|
17
|
-
if (data.orderBy) {
|
|
18
|
-
queryOptions.setOrderBy(data.orderBy);
|
|
19
|
-
}
|
|
20
|
-
if (data.limit) {
|
|
21
|
-
queryOptions.setLimit(data.limit.limit, data.limit.offset);
|
|
22
|
-
}
|
|
23
|
-
return queryOptions;
|
|
24
|
-
}
|
|
25
11
|
getWhere() {
|
|
26
12
|
return this.where;
|
|
27
13
|
}
|
|
@@ -31,8 +31,9 @@ export default class QueryParams {
|
|
|
31
31
|
}
|
|
32
32
|
static createOrderParams(sql, orderBy) {
|
|
33
33
|
let sqlString = `ORDER BY `;
|
|
34
|
-
orderBy.forEach(item => {
|
|
35
|
-
sqlString += `${item.key} ${item.order}
|
|
34
|
+
orderBy.forEach((item, i) => {
|
|
35
|
+
sqlString += `${item.key} ${item.order}`;
|
|
36
|
+
sqlString += orderBy.length - 1 !== i ? ', ' : ' ';
|
|
36
37
|
});
|
|
37
38
|
sql = `${sql} ${sqlString}`;
|
|
38
39
|
return sql;
|
package/dist/types/ConnectorE.js
CHANGED
|
@@ -3,14 +3,4 @@ var ConnectorE;
|
|
|
3
3
|
ConnectorE["or"] = "OR ";
|
|
4
4
|
ConnectorE["and"] = "AND ";
|
|
5
5
|
})(ConnectorE || (ConnectorE = {}));
|
|
6
|
-
function getFromValue(value) {
|
|
7
|
-
switch (value) {
|
|
8
|
-
case "OR ":
|
|
9
|
-
return ConnectorE.or;
|
|
10
|
-
case "AND ":
|
|
11
|
-
default:
|
|
12
|
-
return ConnectorE.and;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
6
|
export default ConnectorE;
|
|
16
|
-
export { getFromValue };
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import OrderByI from "./OrderByI";
|
|
2
|
-
import ParameterI from "./ParameterI";
|
|
3
|
-
export default interface QueryOptionsConfig {
|
|
4
|
-
where: {
|
|
5
|
-
connector: string;
|
|
6
|
-
parameters: ParameterI[];
|
|
7
|
-
};
|
|
8
|
-
orderBy: OrderByI[];
|
|
9
|
-
limit: {
|
|
10
|
-
limit: number;
|
|
11
|
-
offset: number;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|