taon-type-sql 21.0.21 → 21.0.22
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/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib-prod/build-info._auto-generated_.ts +27 -0
- package/lib-prod/builder/column/basic-column.ts +17 -0
- package/lib-prod/builder/column/boolean-column.ts +19 -0
- package/lib-prod/builder/column/comparable-column.ts +56 -0
- package/lib-prod/builder/column/date-column.ts +19 -0
- package/lib-prod/builder/column/number-column.ts +25 -0
- package/lib-prod/builder/column/query-column.ts +34 -0
- package/lib-prod/builder/column/string-column.ts +47 -0
- package/lib-prod/builder/column/value-column.ts +39 -0
- package/lib-prod/builder/condition/{query-column-condition.d.ts → query-column-condition.ts} +20 -5
- package/lib-prod/builder/condition/query-condition-chain.ts +42 -0
- package/lib-prod/builder/condition/{query-condition.d.ts → query-condition.ts} +8 -2
- package/lib-prod/builder/condition/{query-join-condition.d.ts → query-join-condition.ts} +19 -4
- package/lib-prod/builder/helpers/generics-helper.ts +2 -0
- package/lib-prod/builder/helpers/{internal-types.d.ts → internal-types.ts} +25 -9
- package/lib-prod/builder/join/joined-tables-chain.ts +17 -0
- package/lib-prod/builder/join/joined-tables.ts +28 -0
- package/lib-prod/builder/other/{query-ordering.d.ts → query-ordering.ts} +20 -4
- package/lib-prod/builder/query/select-query.ts +68 -0
- package/lib-prod/builder/query/table-condition-query.ts +35 -0
- package/lib-prod/builder/query/table-query.ts +72 -0
- package/lib-prod/builder/{query-source.d.ts → query-source.ts} +19 -8
- package/lib-prod/builder/query-table.ts +34 -0
- package/lib-prod/client/mysql.ts +9 -0
- package/lib-prod/client/pg.ts +9 -0
- package/lib-prod/client/query-processor.ts +89 -0
- package/lib-prod/converter/{param-converter.js → param-converter.ts} +8 -16
- package/lib-prod/converter/parameterized-converter.ts +20 -0
- package/lib-prod/converter/{query-converter.js → query-converter.ts} +113 -101
- package/lib-prod/converter/result-converter.ts +88 -0
- package/lib-prod/converter/sql-converter.ts +7 -0
- package/lib-prod/converter/type-converter.ts +29 -0
- package/lib-prod/converter/{types.d.ts → types.ts} +4 -3
- package/lib-prod/env/env.angular-node-app.ts +66 -0
- package/lib-prod/env/env.docs-webapp.ts +66 -0
- package/lib-prod/env/env.electron-app.ts +66 -0
- package/lib-prod/env/env.mobile-app.ts +66 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.ts +66 -0
- package/lib-prod/env/env.vscode-plugin.ts +66 -0
- package/lib-prod/{index._auto-generated_.js → index._auto-generated_.ts} +0 -1
- package/lib-prod/{index.d.ts → index.ts} +15 -3
- package/lib-prod/lib-info.md +8 -0
- package/lib-prod/migrations/index.ts +2 -0
- package/lib-prod/migrations/migrations-info.md +6 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.js → migrations_index._auto-generated_.ts} +2 -1
- package/lib-prod/package.json +1 -1
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +0 -24
- package/lib-prod/build-info._auto-generated_.js +0 -30
- package/lib-prod/build-info._auto-generated_.js.map +0 -1
- package/lib-prod/builder/column/basic-column.d.ts +0 -8
- package/lib-prod/builder/column/basic-column.js +0 -15
- package/lib-prod/builder/column/basic-column.js.map +0 -1
- package/lib-prod/builder/column/boolean-column.d.ts +0 -9
- package/lib-prod/builder/column/boolean-column.js +0 -15
- package/lib-prod/builder/column/boolean-column.js.map +0 -1
- package/lib-prod/builder/column/comparable-column.d.ts +0 -18
- package/lib-prod/builder/column/comparable-column.js +0 -42
- package/lib-prod/builder/column/comparable-column.js.map +0 -1
- package/lib-prod/builder/column/date-column.d.ts +0 -9
- package/lib-prod/builder/column/date-column.js +0 -15
- package/lib-prod/builder/column/date-column.js.map +0 -1
- package/lib-prod/builder/column/number-column.d.ts +0 -10
- package/lib-prod/builder/column/number-column.js +0 -20
- package/lib-prod/builder/column/number-column.js.map +0 -1
- package/lib-prod/builder/column/query-column.d.ts +0 -18
- package/lib-prod/builder/column/query-column.js +0 -26
- package/lib-prod/builder/column/query-column.js.map +0 -1
- package/lib-prod/builder/column/string-column.d.ts +0 -17
- package/lib-prod/builder/column/string-column.js +0 -37
- package/lib-prod/builder/column/string-column.js.map +0 -1
- package/lib-prod/builder/column/value-column.d.ts +0 -15
- package/lib-prod/builder/column/value-column.js +0 -30
- package/lib-prod/builder/column/value-column.js.map +0 -1
- package/lib-prod/builder/condition/query-column-condition.js +0 -23
- package/lib-prod/builder/condition/query-column-condition.js.map +0 -1
- package/lib-prod/builder/condition/query-condition-chain.d.ts +0 -17
- package/lib-prod/builder/condition/query-condition-chain.js +0 -34
- package/lib-prod/builder/condition/query-condition-chain.js.map +0 -1
- package/lib-prod/builder/condition/query-condition.js +0 -7
- package/lib-prod/builder/condition/query-condition.js.map +0 -1
- package/lib-prod/builder/condition/query-join-condition.js +0 -23
- package/lib-prod/builder/condition/query-join-condition.js.map +0 -1
- package/lib-prod/builder/helpers/generics-helper.d.ts +0 -2
- package/lib-prod/builder/helpers/generics-helper.js +0 -7
- package/lib-prod/builder/helpers/generics-helper.js.map +0 -1
- package/lib-prod/builder/helpers/internal-types.js +0 -4
- package/lib-prod/builder/helpers/internal-types.js.map +0 -1
- package/lib-prod/builder/join/joined-tables-chain.d.ts +0 -11
- package/lib-prod/builder/join/joined-tables-chain.js +0 -18
- package/lib-prod/builder/join/joined-tables-chain.js.map +0 -1
- package/lib-prod/builder/join/joined-tables.d.ts +0 -12
- package/lib-prod/builder/join/joined-tables.js +0 -25
- package/lib-prod/builder/join/joined-tables.js.map +0 -1
- package/lib-prod/builder/other/query-ordering.js +0 -21
- package/lib-prod/builder/other/query-ordering.js.map +0 -1
- package/lib-prod/builder/query/select-query.d.ts +0 -29
- package/lib-prod/builder/query/select-query.js +0 -54
- package/lib-prod/builder/query/select-query.js.map +0 -1
- package/lib-prod/builder/query/table-condition-query.d.ts +0 -16
- package/lib-prod/builder/query/table-condition-query.js +0 -31
- package/lib-prod/builder/query/table-condition-query.js.map +0 -1
- package/lib-prod/builder/query/table-query.d.ts +0 -23
- package/lib-prod/builder/query/table-query.js +0 -60
- package/lib-prod/builder/query/table-query.js.map +0 -1
- package/lib-prod/builder/query-source.js +0 -22
- package/lib-prod/builder/query-source.js.map +0 -1
- package/lib-prod/builder/query-table.d.ts +0 -15
- package/lib-prod/builder/query-table.js +0 -28
- package/lib-prod/builder/query-table.js.map +0 -1
- package/lib-prod/client/mysql.d.ts +0 -5
- package/lib-prod/client/mysql.js +0 -11
- package/lib-prod/client/mysql.js.map +0 -1
- package/lib-prod/client/pg.d.ts +0 -5
- package/lib-prod/client/pg.js +0 -11
- package/lib-prod/client/pg.js.map +0 -1
- package/lib-prod/client/query-processor.d.ts +0 -10
- package/lib-prod/client/query-processor.js +0 -73
- package/lib-prod/client/query-processor.js.map +0 -1
- package/lib-prod/converter/param-converter.d.ts +0 -2
- package/lib-prod/converter/param-converter.js.map +0 -1
- package/lib-prod/converter/parameterized-converter.d.ts +0 -5
- package/lib-prod/converter/parameterized-converter.js +0 -18
- package/lib-prod/converter/parameterized-converter.js.map +0 -1
- package/lib-prod/converter/query-converter.d.ts +0 -2
- package/lib-prod/converter/query-converter.js.map +0 -1
- package/lib-prod/converter/result-converter.d.ts +0 -2
- package/lib-prod/converter/result-converter.js +0 -89
- package/lib-prod/converter/result-converter.js.map +0 -1
- package/lib-prod/converter/sql-converter.d.ts +0 -2
- package/lib-prod/converter/sql-converter.js +0 -9
- package/lib-prod/converter/sql-converter.js.map +0 -1
- package/lib-prod/converter/type-converter.d.ts +0 -4
- package/lib-prod/converter/type-converter.js +0 -43
- package/lib-prod/converter/type-converter.js.map +0 -1
- package/lib-prod/converter/types.js +0 -3
- package/lib-prod/converter/types.js.map +0 -1
- package/lib-prod/env/env.angular-node-app.d.ts +0 -64
- package/lib-prod/env/env.angular-node-app.js +0 -71
- package/lib-prod/env/env.angular-node-app.js.map +0 -1
- package/lib-prod/env/env.docs-webapp.d.ts +0 -64
- package/lib-prod/env/env.docs-webapp.js +0 -71
- package/lib-prod/env/env.docs-webapp.js.map +0 -1
- package/lib-prod/env/env.electron-app.d.ts +0 -64
- package/lib-prod/env/env.electron-app.js +0 -71
- package/lib-prod/env/env.electron-app.js.map +0 -1
- package/lib-prod/env/env.mobile-app.d.ts +0 -64
- package/lib-prod/env/env.mobile-app.js +0 -71
- package/lib-prod/env/env.mobile-app.js.map +0 -1
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +0 -64
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +0 -71
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +0 -1
- package/lib-prod/env/env.vscode-plugin.d.ts +0 -64
- package/lib-prod/env/env.vscode-plugin.js +0 -71
- package/lib-prod/env/env.vscode-plugin.js.map +0 -1
- package/lib-prod/env/index.js +0 -23
- package/lib-prod/env/index.js.map +0 -1
- package/lib-prod/index._auto-generated_.d.ts +0 -0
- package/lib-prod/index._auto-generated_.js.map +0 -1
- package/lib-prod/index.js +0 -48
- package/lib-prod/index.js.map +0 -1
- package/lib-prod/migrations/index.d.ts +0 -1
- package/lib-prod/migrations/index.js +0 -19
- package/lib-prod/migrations/index.js.map +0 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js.map +0 -1
- /package/lib-prod/env/{index.d.ts → index.ts} +0 -0
package/browser/package.json
CHANGED
|
@@ -25,6 +25,6 @@ exports.CURRENT_PACKAGE_TAON_VERSION = 'v21';
|
|
|
25
25
|
/**
|
|
26
26
|
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
27
27
|
*/
|
|
28
|
-
exports.CURRENT_PACKAGE_VERSION = '21.0.
|
|
28
|
+
exports.CURRENT_PACKAGE_VERSION = '21.0.22';
|
|
29
29
|
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
30
30
|
//# sourceMappingURL=build-info._auto-generated_.js.map
|
package/lib/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
2
|
+
/**
|
|
3
|
+
* Autogenerated by current cli tool
|
|
4
|
+
*/
|
|
5
|
+
export const BUILD_FRAMEWORK_CLI_NAME = 'tnp';
|
|
6
|
+
/**
|
|
7
|
+
* This value can be change in taon.jsonc (appId)
|
|
8
|
+
*/
|
|
9
|
+
export const APP_ID = 'com.domain.example.taon-type-sql';
|
|
10
|
+
/**
|
|
11
|
+
* Autogenerated by current cli tool
|
|
12
|
+
*/
|
|
13
|
+
export const BUILD_BASE_HREF = '';
|
|
14
|
+
/**
|
|
15
|
+
* This value can be change in taon.jsonc (overrideNpmName)
|
|
16
|
+
*/
|
|
17
|
+
export const PROJECT_NPM_NAME = 'taon-type-sql';
|
|
18
|
+
/**
|
|
19
|
+
* Taon version from you project taon.json
|
|
20
|
+
*/
|
|
21
|
+
export const CURRENT_PACKAGE_TAON_VERSION = 'v21';
|
|
22
|
+
/**
|
|
23
|
+
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
24
|
+
*/
|
|
25
|
+
export const CURRENT_PACKAGE_VERSION = '21.0.22';
|
|
26
|
+
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
27
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import QueryColumn from "./query-column";
|
|
3
|
+
import NumberColumn from "./number-column";
|
|
4
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
5
|
+
|
|
6
|
+
// This file is only needed because the QueryColumn can't implement its count method b. of circular dependencies
|
|
7
|
+
|
|
8
|
+
export default class BasicColumn<Table extends QueryTable<any, any>, T> extends QueryColumn<Table, T> {
|
|
9
|
+
|
|
10
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
11
|
+
super(table, name, modifiers);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
count(): NumberColumn<Table> {
|
|
15
|
+
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import NumberColumn from "./number-column";
|
|
3
|
+
import ValueColumn from "./value-column";
|
|
4
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default class BooleanColumn<Table extends QueryTable<any, any>> extends ValueColumn<Table, boolean> {
|
|
8
|
+
|
|
9
|
+
protected _type = 'boolean';
|
|
10
|
+
|
|
11
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
12
|
+
super(table, name, modifiers);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
count(): NumberColumn<Table> {
|
|
16
|
+
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import QueryColumnCondition from "../condition/query-column-condition";
|
|
2
|
+
import QueryTable from "../query-table";
|
|
3
|
+
import ValueColumn from "./value-column";
|
|
4
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
abstract class ComparableColumn<Table extends QueryTable<any, any>, T> extends ValueColumn<Table, T> {
|
|
8
|
+
|
|
9
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
10
|
+
super(table, name, modifiers);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
lt(value: T) {
|
|
14
|
+
return new QueryColumnCondition<Table, T>(this, 'lt', value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
gt(value: T) {
|
|
18
|
+
return new QueryColumnCondition<Table, T>(this, 'gt', value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
lte(value: T) {
|
|
22
|
+
return new QueryColumnCondition<Table, T>(this, 'lte', value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
gte(value: T) {
|
|
26
|
+
return new QueryColumnCondition<Table, T>(this, 'gte', value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
in(values: T[]) {
|
|
30
|
+
return new QueryColumnCondition<Table, T>(this, 'in', ...values);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
notIn(values: T[]) {
|
|
34
|
+
return new QueryColumnCondition<Table, T>(this, 'not-in', ...values);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
between(value1: T, value2: T) {
|
|
38
|
+
return new QueryColumnCondition<Table, T>(this, 'between', value1, value2);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
notBetween(value1: T, value2: T) {
|
|
42
|
+
return new QueryColumnCondition<Table, T>(this, 'not-between', value1, value2);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// min/max exists for text columns too, not just numeric and date
|
|
46
|
+
|
|
47
|
+
min(): this {
|
|
48
|
+
return new (<any>this.constructor)(this._table, this._name, this._modifiers.concat({ name: 'min' }));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
max(): this {
|
|
52
|
+
return new (<any>this.constructor)(this._table, this._name, this._modifiers.concat({ name: 'max' }));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default ComparableColumn;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import ComparableColumn from "./comparable-column";
|
|
3
|
+
import NumberColumn from "./number-column";
|
|
4
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default class DateColumn<Table extends QueryTable<any, any>> extends ComparableColumn<Table, Date> {
|
|
8
|
+
|
|
9
|
+
protected _type = 'date';
|
|
10
|
+
|
|
11
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
12
|
+
super(table, name, modifiers);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
count(): NumberColumn<Table> {
|
|
16
|
+
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import ComparableColumn from "./comparable-column";
|
|
3
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default class NumberColumn<Table extends QueryTable<any, any>> extends ComparableColumn<Table, number> {
|
|
7
|
+
|
|
8
|
+
protected _type = 'number';
|
|
9
|
+
|
|
10
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
11
|
+
super(table, name, modifiers);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
count(): NumberColumn<Table> {
|
|
15
|
+
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
sum(): NumberColumn<Table> {
|
|
19
|
+
return new NumberColumn<Table>(this._table, this._name, this._modifiers.concat({ name: 'sum' }));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
avg(): NumberColumn<Table> {
|
|
23
|
+
return new NumberColumn<Table>(this._table, this._name, this._modifiers.concat({ name: 'avg' }));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import NumberColumn from "./number-column";
|
|
3
|
+
import GenericsHelper from "../helpers/generics-helper";
|
|
4
|
+
import QueryColumnCondition from "../condition/query-column-condition";
|
|
5
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
abstract class QueryColumn<Table extends QueryTable<any, any>, T> {
|
|
9
|
+
|
|
10
|
+
protected _$type: GenericsHelper<T>;
|
|
11
|
+
protected _type: string;
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
protected _table: Table,
|
|
15
|
+
protected _name: ColumnName,
|
|
16
|
+
protected _modifiers: ColumnModifier[] = []
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
abstract count(): NumberColumn<Table>; // TODO I had to copy-paste the implementation to every child class to avoid a circular dependency
|
|
20
|
+
|
|
21
|
+
as(alias: string): this {
|
|
22
|
+
return new (<any>this.constructor)(this._table, this._name, this._modifiers.concat({ name: 'as', params: alias }));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isNull() {
|
|
26
|
+
return new QueryColumnCondition<Table, T>(this, 'is-null');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
isNotNull() {
|
|
30
|
+
return new QueryColumnCondition<Table, T>(this, 'is-not-null');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default QueryColumn;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import ComparableColumn from "./comparable-column";
|
|
3
|
+
import NumberColumn from "./number-column";
|
|
4
|
+
import QueryColumnCondition from "../condition/query-column-condition";
|
|
5
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export default class StringColumn<Table extends QueryTable<any, any>> extends ComparableColumn<Table, string> {
|
|
9
|
+
|
|
10
|
+
protected _type = 'string';
|
|
11
|
+
|
|
12
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
13
|
+
super(table, name, modifiers);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
count(): NumberColumn<Table> {
|
|
17
|
+
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
lower(): this {
|
|
21
|
+
return new (<any>this.constructor)(this._table, this._name, this._modifiers.concat({ name: 'lower' }));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
upper(): this {
|
|
25
|
+
return new (<any>this.constructor)(this._table, this._name, this._modifiers.concat({ name: 'upper' }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
contains(value: string) {
|
|
29
|
+
return this.like('%' + value + '%');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
startsWith(value: string) {
|
|
33
|
+
return this.like(value + '%');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
endsWith(value: string) {
|
|
37
|
+
return this.like('%' + value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
like(value: string) {
|
|
41
|
+
return new QueryColumnCondition<Table, string>(this, 'like', value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
notLike(value: string) {
|
|
45
|
+
return new QueryColumnCondition<Table, string>(this, 'not-like', value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import QueryColumnCondition from "../condition/query-column-condition";
|
|
2
|
+
import QueryOrdering from "../other/query-ordering";
|
|
3
|
+
import QueryTable from "../query-table";
|
|
4
|
+
import QueryColumn from "./query-column";
|
|
5
|
+
import QueryCondition from "../condition/query-condition";
|
|
6
|
+
import QueryJoinCondition from "../condition/query-join-condition";
|
|
7
|
+
import {ColumnModifier, ColumnName} from "../helpers/internal-types";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
abstract class ValueColumn<Table extends QueryTable<any, any>, T> extends QueryColumn<Table, T> {
|
|
11
|
+
|
|
12
|
+
constructor(table: Table, name: ColumnName, modifiers: ColumnModifier[] = []) {
|
|
13
|
+
super(table, name, modifiers);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
asc() {
|
|
17
|
+
return new QueryOrdering<Table>(this, 'ASC');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
desc() {
|
|
21
|
+
return new QueryOrdering<Table>(this, 'DESC');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
eq<Table2 extends QueryTable<any, any>>(value: QueryColumn<Table2, T>): QueryJoinCondition<Table, Table2, T>;
|
|
25
|
+
eq(value: T): QueryColumnCondition<Table, T>;
|
|
26
|
+
eq<Table2 extends QueryTable<any, any>>(value: any): QueryCondition<any> {
|
|
27
|
+
if (value instanceof QueryColumn) {
|
|
28
|
+
return new QueryJoinCondition<Table, Table2, T>(this, 'eq', value);
|
|
29
|
+
} else {
|
|
30
|
+
return new QueryColumnCondition<Table, T>(this, 'eq', value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ne(value: T) {
|
|
35
|
+
return new QueryColumnCondition<Table, T>(this, 'ne', value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default ValueColumn;
|
package/lib-prod/builder/condition/{query-column-condition.d.ts → query-column-condition.ts}
RENAMED
|
@@ -2,12 +2,27 @@ import QueryColumn from "../column/query-column";
|
|
|
2
2
|
import QueryTable from "../query-table";
|
|
3
3
|
import QueryCondition from "./query-condition";
|
|
4
4
|
import QueryConditionChain from "./query-condition-chain";
|
|
5
|
-
import {
|
|
5
|
+
import {ConditionType} from "../helpers/internal-types";
|
|
6
|
+
|
|
7
|
+
|
|
6
8
|
export default class QueryColumnCondition<Table extends QueryTable<any, any>, T> extends QueryCondition<Table> {
|
|
9
|
+
|
|
7
10
|
protected _column: QueryColumn<Table, T>;
|
|
8
11
|
protected _type: ConditionType;
|
|
9
12
|
protected _values: T[];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
constructor(column: QueryColumn<Table, T>, type: ConditionType, ...values: T[]) {
|
|
15
|
+
super();
|
|
16
|
+
this._column = column;
|
|
17
|
+
this._type = type;
|
|
18
|
+
this._values = values;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
and<Table2 extends QueryTable<any, any>>(condition: QueryCondition<Table2>): QueryConditionChain<Table | Table2> {
|
|
22
|
+
return new QueryConditionChain<Table | Table2>(this, condition, 'and');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
or<Table2 extends QueryTable<any, any>>(condition: QueryCondition<Table2>): QueryConditionChain<Table | Table2> {
|
|
26
|
+
return new QueryConditionChain<Table | Table2>(this, condition, 'or');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import QueryCondition from "./query-condition";
|
|
3
|
+
import GenericsHelper from "../helpers/generics-helper";
|
|
4
|
+
import {ConditionChainType} from "../helpers/internal-types";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default class QueryConditionChain<Table extends QueryTable<any, any>> extends QueryCondition<Table> {
|
|
8
|
+
|
|
9
|
+
protected _$type: GenericsHelper<Table>;
|
|
10
|
+
|
|
11
|
+
protected _sibling: QueryCondition<any>;
|
|
12
|
+
protected _child: QueryCondition<any>;
|
|
13
|
+
protected _chainType: ConditionChainType;
|
|
14
|
+
protected _parenthesis = false;
|
|
15
|
+
protected _negation = false;
|
|
16
|
+
|
|
17
|
+
constructor(sibling: QueryCondition<any>, child: QueryCondition<any>, chainType: ConditionChainType) {
|
|
18
|
+
super();
|
|
19
|
+
this._sibling = sibling;
|
|
20
|
+
this._child = child;
|
|
21
|
+
this._chainType = chainType;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// TODO how to call this
|
|
25
|
+
$() {
|
|
26
|
+
this._parenthesis = true;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
not() {
|
|
31
|
+
this._negation = true;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
and<Table2 extends QueryTable<any, any>>(condition: QueryCondition<Table2>): QueryConditionChain<Table | Table2> {
|
|
36
|
+
return new QueryConditionChain<Table | Table2>(this, condition, 'and');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
or<Table2 extends QueryTable<any, any>>(condition: QueryCondition<Table2>): QueryConditionChain<Table | Table2> {
|
|
40
|
+
return new QueryConditionChain<Table | Table2>(this, condition, 'or');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import QueryTable from "../query-table";
|
|
2
2
|
import QueryConditionChain from "./query-condition-chain";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// TODO I had to copy-paste the method implementations to every child class to avoid circular dependencies
|
|
5
|
+
|
|
6
|
+
abstract class QueryCondition<Table extends QueryTable<any, any>> {
|
|
7
|
+
|
|
4
8
|
abstract and<Table2 extends QueryTable<any, any>>(condition: QueryCondition<Table2>): QueryConditionChain<Table | Table2>;
|
|
9
|
+
|
|
5
10
|
abstract or<Table2 extends QueryTable<any, any>>(condition: QueryCondition<Table2>): QueryConditionChain<Table | Table2>;
|
|
6
11
|
}
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
export default QueryCondition;
|
|
@@ -2,11 +2,26 @@ import QueryColumn from "../column/query-column";
|
|
|
2
2
|
import QueryTable from "../query-table";
|
|
3
3
|
import QueryCondition from "./query-condition";
|
|
4
4
|
import QueryConditionChain from "./query-condition-chain";
|
|
5
|
+
|
|
6
|
+
|
|
5
7
|
export default class QueryJoinCondition<Table1 extends QueryTable<any, any>, Table2 extends QueryTable<any, any>, T> extends QueryCondition<Table1 | Table2> {
|
|
8
|
+
|
|
6
9
|
protected _column: QueryColumn<Table1, T>;
|
|
7
10
|
protected _type: string;
|
|
8
11
|
protected _otherColumn: QueryColumn<Table2, T>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
constructor(column: QueryColumn<Table1, T>, type: string, otherColumn: QueryColumn<Table2, T>) {
|
|
14
|
+
super();
|
|
15
|
+
this._column = column;
|
|
16
|
+
this._type = type;
|
|
17
|
+
this._otherColumn = otherColumn;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
and<Table3 extends QueryTable<any, any>>(condition: QueryCondition<Table3>): QueryConditionChain<Table1 | Table2 | Table3> {
|
|
21
|
+
return new QueryConditionChain<Table1 | Table2 | Table3>(this, condition, 'and');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
or<Table3 extends QueryTable<any, any>>(condition: QueryCondition<Table3>): QueryConditionChain<Table1 | Table2 | Table3> {
|
|
25
|
+
return new QueryConditionChain<Table1 | Table2 | Table3>(this, condition, 'or');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,15 +1,31 @@
|
|
|
1
|
+
// query:
|
|
2
|
+
|
|
1
3
|
export type QueryAction = 'select' | 'insert' | 'update' | 'delete';
|
|
4
|
+
|
|
5
|
+
// columns:
|
|
6
|
+
|
|
2
7
|
export type ColumnModifierType = 'as' | 'count' | 'min' | 'min' | 'max' | 'sum' | 'avg' | 'lower' | 'upper';
|
|
8
|
+
|
|
3
9
|
export interface ColumnModifier {
|
|
4
|
-
name: ColumnModifierType
|
|
5
|
-
params?: any
|
|
10
|
+
name: ColumnModifierType,
|
|
11
|
+
params?: any
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
export type ColumnName = string | { name: string, alias: string };
|
|
15
|
+
|
|
16
|
+
export type ColumnType = 'boolean' | 'number' | 'string' | 'date'; // FIXME use this in the columns, but it causes type errors
|
|
17
|
+
|
|
18
|
+
// conditions:
|
|
19
|
+
|
|
12
20
|
export type ConditionChainType = 'or' | 'and';
|
|
13
|
-
|
|
21
|
+
|
|
22
|
+
export type ConditionType = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'not-in' | 'between' | 'not-between'
|
|
23
|
+
| 'like' | 'not-like' | 'is-null' | 'is-not-null';
|
|
24
|
+
|
|
25
|
+
// joins:
|
|
26
|
+
|
|
14
27
|
export type JoinType = 'inner' | 'left' | 'right' | 'full';
|
|
15
|
-
|
|
28
|
+
|
|
29
|
+
// processor:
|
|
30
|
+
|
|
31
|
+
export type QueryProcessor = (query: any) => Promise<any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import QueryJoinCondition from "../condition/query-join-condition";
|
|
3
|
+
import JoinedTables from "./joined-tables";
|
|
4
|
+
import {JoinType} from "../helpers/internal-types";
|
|
5
|
+
|
|
6
|
+
export default class JoinedTablesChain<Tables extends QueryTable<any, any>> {
|
|
7
|
+
|
|
8
|
+
constructor(
|
|
9
|
+
protected _table: QueryTable<any, any>,
|
|
10
|
+
protected _modifier: JoinType,
|
|
11
|
+
protected _parent: JoinedTables<Tables> | QueryTable<any, any>
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
on(condition: QueryJoinCondition<Tables, Tables, any>): JoinedTables<Tables> {
|
|
15
|
+
return new JoinedTables(condition, this);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import JoinedTablesChain from "./joined-tables-chain";
|
|
3
|
+
import QueryJoinCondition from "../condition/query-join-condition";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default class JoinedTables<Tables extends QueryTable<any, any>> {
|
|
7
|
+
|
|
8
|
+
constructor(
|
|
9
|
+
protected _condition: QueryJoinCondition<Tables, Tables, any>,
|
|
10
|
+
protected _parent: JoinedTablesChain<Tables>
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
innerJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable> {
|
|
14
|
+
return new JoinedTablesChain(table, 'inner', this);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
leftJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable> {
|
|
18
|
+
return new JoinedTablesChain(table, 'left', this);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
rightJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable> {
|
|
22
|
+
return new JoinedTablesChain(table, 'right', this);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fullJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable> {
|
|
26
|
+
return new JoinedTablesChain(table, 'full', this);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import QueryColumn from "../column/query-column";
|
|
2
2
|
import QueryTable from "../query-table";
|
|
3
|
+
|
|
4
|
+
|
|
3
5
|
export default class QueryOrdering<Table extends QueryTable<any, any>> {
|
|
6
|
+
|
|
4
7
|
protected _column: QueryColumn<Table, any>;
|
|
5
8
|
protected _direction: 'ASC' | 'DESC';
|
|
6
9
|
protected _nullsPosition: 'FIRST' | 'LAST';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
constructor(column: QueryColumn<Table, any>, direction: 'ASC' | 'DESC') {
|
|
12
|
+
this._column = column;
|
|
13
|
+
this._direction = direction;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
nullsFirst(): this {
|
|
17
|
+
this._nullsPosition = 'FIRST';
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
nullsLast(): this {
|
|
22
|
+
this._nullsPosition = 'LAST';
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import QueryCondition from "../condition/query-condition";
|
|
2
|
+
import QueryOrdering from "../other/query-ordering";
|
|
3
|
+
import QueryTable from "../query-table";
|
|
4
|
+
import QueryColumn from "../column/query-column";
|
|
5
|
+
import { QueryProcessor, QueryAction } from "../helpers/internal-types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export default class SelectQuery<Entity, Table extends QueryTable<Entity, any>> {
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
protected _queryProcessor: QueryProcessor,
|
|
12
|
+
protected _tables: Table[]
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
protected _distinct = false;
|
|
16
|
+
protected _offset: number;
|
|
17
|
+
protected _limit: number;
|
|
18
|
+
protected _conditions: QueryCondition<Table>[] = [];
|
|
19
|
+
protected _groupBy: QueryColumn<Table, any>[] = [];
|
|
20
|
+
protected _having: QueryCondition<Table>[] = [];
|
|
21
|
+
protected _orderings: (QueryColumn<Table, any> | QueryOrdering<Table>)[] = [];
|
|
22
|
+
protected _columns: QueryColumn<Table, any>[] = [];
|
|
23
|
+
protected _action: QueryAction;
|
|
24
|
+
|
|
25
|
+
offset(offset: number): this {
|
|
26
|
+
this._offset = offset;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
limit(limit: number): this {
|
|
31
|
+
this._limit = limit;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
distinct(): this {
|
|
36
|
+
this._distinct = true;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
where(...conditions: QueryCondition<Table>[]): this {
|
|
41
|
+
this._conditions = conditions;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
groupBy(...columns: QueryColumn<Table, any>[]): this {
|
|
46
|
+
this._groupBy = columns;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
having(...conditions: QueryCondition<Table>[]): this {
|
|
51
|
+
this._having = conditions;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
orderBy(...orderings: (QueryColumn<Table, any> | QueryOrdering<Table>)[]): this {
|
|
56
|
+
this._orderings = orderings;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
select(): Promise<Entity[]>
|
|
61
|
+
select<T>(column: QueryColumn<Table, T>): Promise<T[]>
|
|
62
|
+
select(...columns: QueryColumn<Table, any>[]): Promise<any[]>
|
|
63
|
+
select(...columns: QueryColumn<Table, any>[]): Promise<any[]> {
|
|
64
|
+
this._columns = columns;
|
|
65
|
+
this._action = 'select';
|
|
66
|
+
return this._queryProcessor(this);
|
|
67
|
+
}
|
|
68
|
+
}
|