@dascompany/database 2.1.5 → 3.0.0
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/Table.d.ts +2 -2
- package/dist/query/BindParams.d.ts +2 -2
- package/dist/query/BindParams.js +6 -4
- package/dist/query/QueryOptions.d.ts +13 -2
- package/dist/query/QueryOptions.js +28 -18
- package/dist/query/QueryParams.d.ts +2 -2
- package/dist/query/QueryParams.js +8 -5
- package/package.json +1 -1
package/dist/Table.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Connection from './Connection';
|
|
2
2
|
import Query from './query/Query';
|
|
3
|
-
import
|
|
3
|
+
import QueryOptions from './query/QueryOptions';
|
|
4
4
|
export default abstract class Table {
|
|
5
5
|
private connection;
|
|
6
6
|
constructor(connection: Connection);
|
|
7
|
-
createQuery(queryString: string, options?:
|
|
7
|
+
createQuery(queryString: string, options?: QueryOptions): Query;
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import QueryOptionsI from "../types/QueryOptionsI";
|
|
2
1
|
import Query from "./Query";
|
|
2
|
+
import QueryOptions from "./QueryOptions";
|
|
3
3
|
export default class BindParams {
|
|
4
|
-
static bindParams(query: Query, options:
|
|
4
|
+
static bindParams(query: Query, options: QueryOptions): void;
|
|
5
5
|
private static bindWhereParams;
|
|
6
6
|
private static bindWhereParam;
|
|
7
7
|
private static bindLimitParams;
|
package/dist/query/BindParams.js
CHANGED
|
@@ -2,10 +2,12 @@ import ParameterType from "../types/parameters/ParameterType";
|
|
|
2
2
|
import QueryParamCreator from "./QueryParamCreator";
|
|
3
3
|
export default class BindParams {
|
|
4
4
|
static bindParams(query, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
BindParams.
|
|
5
|
+
const where = options.getWhere();
|
|
6
|
+
const limit = options.getLimit();
|
|
7
|
+
if (where)
|
|
8
|
+
BindParams.bindWhereParams(query, where.parameters);
|
|
9
|
+
if (limit)
|
|
10
|
+
BindParams.bindLimitParams(query, limit);
|
|
9
11
|
}
|
|
10
12
|
static bindWhereParams(query, parameters) {
|
|
11
13
|
parameters.forEach((parameter) => {
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import ResultLimitationI from "../types/ResultLimitationI";
|
|
2
2
|
import OrderByI from "../types/OrderByI";
|
|
3
|
+
import WhereOptionI from "../types/WhereOptionI";
|
|
4
|
+
import ParameterI from "../types/ParameterI";
|
|
5
|
+
import ConnectorE from "../types/ConnectorE";
|
|
3
6
|
export default class QueryOptions {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
private where;
|
|
8
|
+
private orderBy;
|
|
9
|
+
private limit;
|
|
10
|
+
constructor();
|
|
11
|
+
getWhere(): WhereOptionI | null;
|
|
12
|
+
getOrderBy(): OrderByI[] | null;
|
|
13
|
+
getLimit(): ResultLimitationI | null;
|
|
14
|
+
setWhere(parameters: ParameterI[], connector?: ConnectorE): void;
|
|
15
|
+
setOrderBy(orderBy: OrderByI[]): void;
|
|
16
|
+
setLimit(limit: number, offset: number): void;
|
|
6
17
|
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Filters from "../utils/Filters";
|
|
3
|
-
import Parameters from "../utils/Parameters";
|
|
1
|
+
import ConnectorE from "../types/ConnectorE";
|
|
4
2
|
export default class QueryOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
table.push({ key, order });
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return table;
|
|
3
|
+
where;
|
|
4
|
+
orderBy;
|
|
5
|
+
limit;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.where = null;
|
|
8
|
+
this.orderBy = null;
|
|
9
|
+
this.limit = null;
|
|
16
10
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
getWhere() {
|
|
12
|
+
return this.where;
|
|
13
|
+
}
|
|
14
|
+
getOrderBy() {
|
|
15
|
+
return this.orderBy;
|
|
16
|
+
}
|
|
17
|
+
getLimit() {
|
|
18
|
+
return this.limit;
|
|
19
|
+
}
|
|
20
|
+
setWhere(parameters, connector = ConnectorE.and) {
|
|
21
|
+
this.where = {
|
|
22
|
+
connector,
|
|
23
|
+
parameters
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
setOrderBy(orderBy) {
|
|
27
|
+
this.orderBy = orderBy;
|
|
28
|
+
}
|
|
29
|
+
setLimit(limit, offset) {
|
|
30
|
+
this.limit = {
|
|
21
31
|
limit,
|
|
22
32
|
offset
|
|
23
33
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import QueryOptions from './QueryOptions';
|
|
2
2
|
export default class QueryParams {
|
|
3
|
-
static createParams(queryString: string, options:
|
|
3
|
+
static createParams(queryString: string, options: QueryOptions): string;
|
|
4
4
|
private static createWhereParams;
|
|
5
5
|
private static createParamsSql;
|
|
6
6
|
private static createOrderParams;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import QueryParamsCreator from './QueryParamCreator';
|
|
2
2
|
export default class QueryParams {
|
|
3
3
|
static createParams(queryString, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const where = options.getWhere();
|
|
5
|
+
const orderBy = options.getOrderBy();
|
|
6
|
+
const limit = options.getLimit();
|
|
7
|
+
if (where)
|
|
8
|
+
queryString = QueryParams.createWhereParams(queryString, where);
|
|
9
|
+
if (orderBy)
|
|
10
|
+
queryString = QueryParams.createOrderParams(queryString, orderBy);
|
|
11
|
+
if (limit)
|
|
9
12
|
queryString += `LIMIT $limit::BIGINT OFFSET $offset::BIGINT`;
|
|
10
13
|
return queryString;
|
|
11
14
|
}
|