taon-type-sql 21.0.27 → 21.0.28
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_.d.ts +24 -0
- package/lib-prod/build-info._auto-generated_.js +30 -0
- package/lib-prod/build-info._auto-generated_.js.map +1 -0
- package/lib-prod/builder/column/basic-column.d.ts +8 -0
- package/lib-prod/builder/column/basic-column.js +15 -0
- package/lib-prod/builder/column/basic-column.js.map +1 -0
- package/lib-prod/builder/column/boolean-column.d.ts +9 -0
- package/lib-prod/builder/column/boolean-column.js +15 -0
- package/lib-prod/builder/column/boolean-column.js.map +1 -0
- package/lib-prod/builder/column/comparable-column.d.ts +18 -0
- package/lib-prod/builder/column/comparable-column.js +42 -0
- package/lib-prod/builder/column/comparable-column.js.map +1 -0
- package/lib-prod/builder/column/date-column.d.ts +9 -0
- package/lib-prod/builder/column/date-column.js +15 -0
- package/lib-prod/builder/column/date-column.js.map +1 -0
- package/lib-prod/builder/column/number-column.d.ts +10 -0
- package/lib-prod/builder/column/number-column.js +20 -0
- package/lib-prod/builder/column/number-column.js.map +1 -0
- package/lib-prod/builder/column/query-column.d.ts +18 -0
- package/lib-prod/builder/column/query-column.js +26 -0
- package/lib-prod/builder/column/query-column.js.map +1 -0
- package/lib-prod/builder/column/string-column.d.ts +17 -0
- package/lib-prod/builder/column/string-column.js +37 -0
- package/lib-prod/builder/column/string-column.js.map +1 -0
- package/lib-prod/builder/column/value-column.d.ts +15 -0
- package/lib-prod/builder/column/value-column.js +30 -0
- package/lib-prod/builder/column/value-column.js.map +1 -0
- package/lib-prod/builder/condition/query-column-condition.d.ts +13 -0
- package/lib-prod/builder/condition/query-column-condition.js +23 -0
- package/lib-prod/builder/condition/query-column-condition.js.map +1 -0
- package/lib-prod/builder/condition/query-condition-chain.d.ts +17 -0
- package/lib-prod/builder/condition/query-condition-chain.js +34 -0
- package/lib-prod/builder/condition/query-condition-chain.js.map +1 -0
- package/lib-prod/builder/condition/query-condition.d.ts +7 -0
- package/lib-prod/builder/condition/query-condition.js +7 -0
- package/lib-prod/builder/condition/query-condition.js.map +1 -0
- package/lib-prod/builder/condition/query-join-condition.d.ts +12 -0
- package/lib-prod/builder/condition/query-join-condition.js +23 -0
- package/lib-prod/builder/condition/query-join-condition.js.map +1 -0
- package/lib-prod/builder/helpers/generics-helper.d.ts +2 -0
- package/lib-prod/builder/helpers/generics-helper.js +7 -0
- package/lib-prod/builder/helpers/generics-helper.js.map +1 -0
- package/lib-prod/builder/helpers/internal-types.d.ts +15 -0
- package/lib-prod/builder/helpers/internal-types.js +4 -0
- package/lib-prod/builder/helpers/internal-types.js.map +1 -0
- package/lib-prod/builder/join/joined-tables-chain.d.ts +11 -0
- package/lib-prod/builder/join/joined-tables-chain.js +18 -0
- package/lib-prod/builder/join/joined-tables-chain.js.map +1 -0
- package/lib-prod/builder/join/joined-tables.d.ts +12 -0
- package/lib-prod/builder/join/joined-tables.js +25 -0
- package/lib-prod/builder/join/joined-tables.js.map +1 -0
- package/lib-prod/builder/other/query-ordering.d.ts +10 -0
- package/lib-prod/builder/other/query-ordering.js +21 -0
- package/lib-prod/builder/other/query-ordering.js.map +1 -0
- package/lib-prod/builder/query/select-query.d.ts +29 -0
- package/lib-prod/builder/query/select-query.js +54 -0
- package/lib-prod/builder/query/select-query.js.map +1 -0
- package/lib-prod/builder/query/table-condition-query.d.ts +16 -0
- package/lib-prod/builder/query/table-condition-query.js +31 -0
- package/lib-prod/builder/query/table-condition-query.js.map +1 -0
- package/lib-prod/builder/query/table-query.d.ts +23 -0
- package/lib-prod/builder/query/table-query.js +60 -0
- package/lib-prod/builder/query/table-query.js.map +1 -0
- package/lib-prod/builder/query-source.d.ts +14 -0
- package/lib-prod/builder/query-source.js +22 -0
- package/lib-prod/builder/query-source.js.map +1 -0
- package/lib-prod/builder/query-table.d.ts +15 -0
- package/lib-prod/builder/query-table.js +28 -0
- package/lib-prod/builder/query-table.js.map +1 -0
- package/lib-prod/client/mysql.d.ts +5 -0
- package/lib-prod/client/mysql.js +11 -0
- package/lib-prod/client/mysql.js.map +1 -0
- package/lib-prod/client/pg.d.ts +5 -0
- package/lib-prod/client/pg.js +11 -0
- package/lib-prod/client/pg.js.map +1 -0
- package/lib-prod/client/query-processor.d.ts +10 -0
- package/lib-prod/client/query-processor.js +73 -0
- package/lib-prod/client/query-processor.js.map +1 -0
- package/lib-prod/converter/param-converter.d.ts +2 -0
- package/lib-prod/converter/param-converter.js +31 -0
- package/lib-prod/converter/param-converter.js.map +1 -0
- package/lib-prod/converter/parameterized-converter.d.ts +5 -0
- package/lib-prod/converter/parameterized-converter.js +18 -0
- package/lib-prod/converter/parameterized-converter.js.map +1 -0
- package/lib-prod/converter/query-converter.d.ts +2 -0
- package/lib-prod/converter/query-converter.js +284 -0
- package/lib-prod/converter/query-converter.js.map +1 -0
- package/lib-prod/converter/result-converter.d.ts +2 -0
- package/lib-prod/converter/result-converter.js +89 -0
- package/lib-prod/converter/result-converter.js.map +1 -0
- package/lib-prod/converter/sql-converter.d.ts +2 -0
- package/lib-prod/converter/sql-converter.js +9 -0
- package/lib-prod/converter/sql-converter.js.map +1 -0
- package/lib-prod/converter/type-converter.d.ts +4 -0
- package/lib-prod/converter/type-converter.js +43 -0
- package/lib-prod/converter/type-converter.js.map +1 -0
- package/lib-prod/converter/types.d.ts +5 -0
- package/lib-prod/converter/types.js +3 -0
- package/lib-prod/converter/types.js.map +1 -0
- package/lib-prod/env/env.angular-node-app.d.ts +64 -0
- package/lib-prod/env/env.angular-node-app.js +71 -0
- package/lib-prod/env/env.angular-node-app.js.map +1 -0
- package/lib-prod/env/env.docs-webapp.d.ts +64 -0
- package/lib-prod/env/env.docs-webapp.js +71 -0
- package/lib-prod/env/env.docs-webapp.js.map +1 -0
- package/lib-prod/env/env.electron-app.d.ts +64 -0
- package/lib-prod/env/env.electron-app.js +71 -0
- package/lib-prod/env/env.electron-app.js.map +1 -0
- package/lib-prod/env/env.mobile-app.d.ts +64 -0
- package/lib-prod/env/env.mobile-app.js +71 -0
- package/lib-prod/env/env.mobile-app.js.map +1 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +64 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +71 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -0
- package/lib-prod/env/env.vscode-plugin.d.ts +64 -0
- package/lib-prod/env/env.vscode-plugin.js +71 -0
- package/lib-prod/env/env.vscode-plugin.js.map +1 -0
- package/lib-prod/env/index.d.ts +6 -0
- package/lib-prod/env/index.js +23 -0
- package/lib-prod/env/index.js.map +1 -0
- package/lib-prod/index._auto-generated_.d.ts +0 -0
- package/lib-prod/index._auto-generated_.js +6 -0
- package/lib-prod/index._auto-generated_.js.map +1 -0
- package/lib-prod/index.d.ts +25 -0
- package/lib-prod/index.js +48 -0
- package/lib-prod/index.js.map +1 -0
- package/lib-prod/migrations/index.d.ts +1 -0
- package/lib-prod/migrations/index.js +19 -0
- package/lib-prod/migrations/index.js.map +1 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js +4 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js.map +1 -0
- 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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// TODO In TS generic parameters not used in the class are not enforced, so I have to add dummy fields that use them. Replace with nominal typing
|
|
4
|
+
class GenericsHelper {
|
|
5
|
+
}
|
|
6
|
+
exports.default = GenericsHelper;
|
|
7
|
+
//# sourceMappingURL=generics-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generics-helper.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AACA,iJAAiJ;AACjJ,MAAqB,cAAc;CAAM;AAAzC,iCAAyC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type QueryAction = 'select' | 'insert' | 'update' | 'delete';
|
|
2
|
+
export type ColumnModifierType = 'as' | 'count' | 'min' | 'min' | 'max' | 'sum' | 'avg' | 'lower' | 'upper';
|
|
3
|
+
export interface ColumnModifier {
|
|
4
|
+
name: ColumnModifierType;
|
|
5
|
+
params?: any;
|
|
6
|
+
}
|
|
7
|
+
export type ColumnName = string | {
|
|
8
|
+
name: string;
|
|
9
|
+
alias: string;
|
|
10
|
+
};
|
|
11
|
+
export type ColumnType = 'boolean' | 'number' | 'string' | 'date';
|
|
12
|
+
export type ConditionChainType = 'or' | 'and';
|
|
13
|
+
export type ConditionType = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'not-in' | 'between' | 'not-between' | 'like' | 'not-like' | 'is-null' | 'is-not-null';
|
|
14
|
+
export type JoinType = 'inner' | 'left' | 'right' | 'full';
|
|
15
|
+
export type QueryProcessor = (query: any) => Promise<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-types.js","sourceRoot":"","sources":[""],"names":[],"mappings":";AACA,SAAS"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export default class JoinedTablesChain<Tables extends QueryTable<any, any>> {
|
|
6
|
+
protected _table: QueryTable<any, any>;
|
|
7
|
+
protected _modifier: JoinType;
|
|
8
|
+
protected _parent: JoinedTables<Tables> | QueryTable<any, any>;
|
|
9
|
+
constructor(_table: QueryTable<any, any>, _modifier: JoinType, _parent: JoinedTables<Tables> | QueryTable<any, any>);
|
|
10
|
+
on(condition: QueryJoinCondition<Tables, Tables, any>): JoinedTables<Tables>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const joined_tables_1 = require("./joined-tables");
|
|
4
|
+
class JoinedTablesChain {
|
|
5
|
+
_table;
|
|
6
|
+
_modifier;
|
|
7
|
+
_parent;
|
|
8
|
+
constructor(_table, _modifier, _parent) {
|
|
9
|
+
this._table = _table;
|
|
10
|
+
this._modifier = _modifier;
|
|
11
|
+
this._parent = _parent;
|
|
12
|
+
}
|
|
13
|
+
on(condition) {
|
|
14
|
+
return new joined_tables_1.default(condition, this);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = JoinedTablesChain;
|
|
18
|
+
//# sourceMappingURL=joined-tables-chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joined-tables-chain.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAEA,mDAA2C;AAG3C,MAAqB,iBAAiB;IAGpB;IACA;IACA;IAHd,YACc,MAA4B,EAC5B,SAAmB,EACnB,OAAoD;QAFpD,WAAM,GAAN,MAAM,CAAsB;QAC5B,cAAS,GAAT,SAAS,CAAU;QACnB,YAAO,GAAP,OAAO,CAA6C;IAC/D,CAAC;IAEJ,EAAE,CAAC,SAAkD;QACjD,OAAO,IAAI,uBAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;CACJ;AAXD,oCAWC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import JoinedTablesChain from "./joined-tables-chain";
|
|
3
|
+
import QueryJoinCondition from "../condition/query-join-condition";
|
|
4
|
+
export default class JoinedTables<Tables extends QueryTable<any, any>> {
|
|
5
|
+
protected _condition: QueryJoinCondition<Tables, Tables, any>;
|
|
6
|
+
protected _parent: JoinedTablesChain<Tables>;
|
|
7
|
+
constructor(_condition: QueryJoinCondition<Tables, Tables, any>, _parent: JoinedTablesChain<Tables>);
|
|
8
|
+
innerJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable>;
|
|
9
|
+
leftJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable>;
|
|
10
|
+
rightJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable>;
|
|
11
|
+
fullJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<Tables | JoinTable>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const joined_tables_chain_1 = require("./joined-tables-chain");
|
|
4
|
+
class JoinedTables {
|
|
5
|
+
_condition;
|
|
6
|
+
_parent;
|
|
7
|
+
constructor(_condition, _parent) {
|
|
8
|
+
this._condition = _condition;
|
|
9
|
+
this._parent = _parent;
|
|
10
|
+
}
|
|
11
|
+
innerJoin(table) {
|
|
12
|
+
return new joined_tables_chain_1.default(table, 'inner', this);
|
|
13
|
+
}
|
|
14
|
+
leftJoin(table) {
|
|
15
|
+
return new joined_tables_chain_1.default(table, 'left', this);
|
|
16
|
+
}
|
|
17
|
+
rightJoin(table) {
|
|
18
|
+
return new joined_tables_chain_1.default(table, 'right', this);
|
|
19
|
+
}
|
|
20
|
+
fullJoin(table) {
|
|
21
|
+
return new joined_tables_chain_1.default(table, 'full', this);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = JoinedTables;
|
|
25
|
+
//# sourceMappingURL=joined-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joined-tables.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AACA,+DAAsD;AAItD,MAAqB,YAAY;IAGf;IACA;IAFd,YACc,UAAmD,EACnD,OAAkC;QADlC,eAAU,GAAV,UAAU,CAAyC;QACnD,YAAO,GAAP,OAAO,CAA2B;IAC7C,CAAC;IAEJ,SAAS,CAAyC,KAAgB;QAC9D,OAAO,IAAI,6BAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ,CAAyC,KAAgB;QAC7D,OAAO,IAAI,6BAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,SAAS,CAAyC,KAAgB;QAC9D,OAAO,IAAI,6BAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ,CAAyC,KAAgB;QAC7D,OAAO,IAAI,6BAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACJ;AAtBD,+BAsBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import QueryColumn from "../column/query-column";
|
|
2
|
+
import QueryTable from "../query-table";
|
|
3
|
+
export default class QueryOrdering<Table extends QueryTable<any, any>> {
|
|
4
|
+
protected _column: QueryColumn<Table, any>;
|
|
5
|
+
protected _direction: 'ASC' | 'DESC';
|
|
6
|
+
protected _nullsPosition: 'FIRST' | 'LAST';
|
|
7
|
+
constructor(column: QueryColumn<Table, any>, direction: 'ASC' | 'DESC');
|
|
8
|
+
nullsFirst(): this;
|
|
9
|
+
nullsLast(): this;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class QueryOrdering {
|
|
4
|
+
_column;
|
|
5
|
+
_direction;
|
|
6
|
+
_nullsPosition;
|
|
7
|
+
constructor(column, direction) {
|
|
8
|
+
this._column = column;
|
|
9
|
+
this._direction = direction;
|
|
10
|
+
}
|
|
11
|
+
nullsFirst() {
|
|
12
|
+
this._nullsPosition = 'FIRST';
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
nullsLast() {
|
|
16
|
+
this._nullsPosition = 'LAST';
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = QueryOrdering;
|
|
21
|
+
//# sourceMappingURL=query-ordering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-ordering.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAIA,MAAqB,aAAa;IAEpB,OAAO,CAA0B;IACjC,UAAU,CAAiB;IAC3B,cAAc,CAAmB;IAE3C,YAAY,MAA+B,EAAE,SAAyB;QAClE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAED,UAAU;QACN,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,SAAS;QACL,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ;AArBD,gCAqBC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
export default class SelectQuery<Entity, Table extends QueryTable<Entity, any>> {
|
|
7
|
+
protected _queryProcessor: QueryProcessor;
|
|
8
|
+
protected _tables: Table[];
|
|
9
|
+
constructor(_queryProcessor: QueryProcessor, _tables: Table[]);
|
|
10
|
+
protected _distinct: boolean;
|
|
11
|
+
protected _offset: number;
|
|
12
|
+
protected _limit: number;
|
|
13
|
+
protected _conditions: QueryCondition<Table>[];
|
|
14
|
+
protected _groupBy: QueryColumn<Table, any>[];
|
|
15
|
+
protected _having: QueryCondition<Table>[];
|
|
16
|
+
protected _orderings: (QueryColumn<Table, any> | QueryOrdering<Table>)[];
|
|
17
|
+
protected _columns: QueryColumn<Table, any>[];
|
|
18
|
+
protected _action: QueryAction;
|
|
19
|
+
offset(offset: number): this;
|
|
20
|
+
limit(limit: number): this;
|
|
21
|
+
distinct(): this;
|
|
22
|
+
where(...conditions: QueryCondition<Table>[]): this;
|
|
23
|
+
groupBy(...columns: QueryColumn<Table, any>[]): this;
|
|
24
|
+
having(...conditions: QueryCondition<Table>[]): this;
|
|
25
|
+
orderBy(...orderings: (QueryColumn<Table, any> | QueryOrdering<Table>)[]): this;
|
|
26
|
+
select(): Promise<Entity[]>;
|
|
27
|
+
select<T>(column: QueryColumn<Table, T>): Promise<T[]>;
|
|
28
|
+
select(...columns: QueryColumn<Table, any>[]): Promise<any[]>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class SelectQuery {
|
|
4
|
+
_queryProcessor;
|
|
5
|
+
_tables;
|
|
6
|
+
constructor(_queryProcessor, _tables) {
|
|
7
|
+
this._queryProcessor = _queryProcessor;
|
|
8
|
+
this._tables = _tables;
|
|
9
|
+
}
|
|
10
|
+
_distinct = false;
|
|
11
|
+
_offset;
|
|
12
|
+
_limit;
|
|
13
|
+
_conditions = [];
|
|
14
|
+
_groupBy = [];
|
|
15
|
+
_having = [];
|
|
16
|
+
_orderings = [];
|
|
17
|
+
_columns = [];
|
|
18
|
+
_action;
|
|
19
|
+
offset(offset) {
|
|
20
|
+
this._offset = offset;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
limit(limit) {
|
|
24
|
+
this._limit = limit;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
distinct() {
|
|
28
|
+
this._distinct = true;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
where(...conditions) {
|
|
32
|
+
this._conditions = conditions;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
groupBy(...columns) {
|
|
36
|
+
this._groupBy = columns;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
having(...conditions) {
|
|
40
|
+
this._having = conditions;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
orderBy(...orderings) {
|
|
44
|
+
this._orderings = orderings;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
select(...columns) {
|
|
48
|
+
this._columns = columns;
|
|
49
|
+
this._action = 'select';
|
|
50
|
+
return this._queryProcessor(this);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = SelectQuery;
|
|
54
|
+
//# sourceMappingURL=select-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-query.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAOA,MAAqB,WAAW;IAGd;IACA;IAFd,YACc,eAA+B,EAC/B,OAAgB;QADhB,oBAAe,GAAf,eAAe,CAAgB;QAC/B,YAAO,GAAP,OAAO,CAAS;IAC3B,CAAC;IAEM,SAAS,GAAG,KAAK,CAAC;IAClB,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,WAAW,GAA4B,EAAE,CAAC;IAC1C,QAAQ,GAA8B,EAAE,CAAC;IACzC,OAAO,GAA4B,EAAE,CAAC;IACtC,UAAU,GAAuD,EAAE,CAAC;IACpE,QAAQ,GAA8B,EAAE,CAAC;IACzC,OAAO,CAAc;IAE/B,MAAM,CAAC,MAAc;QACjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAa;QACf,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,GAAG,UAAmC;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,GAAG,OAAkC;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,GAAG,UAAmC;QACzC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,GAAG,SAA6D;QACpE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAKD,MAAM,CAAC,GAAG,OAAkC;QACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACJ;AA5DD,8BA4DC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import QueryCondition from "../condition/query-condition";
|
|
3
|
+
import QueryColumn from "../column/query-column";
|
|
4
|
+
import { QueryProcessor, QueryAction } from "../helpers/internal-types";
|
|
5
|
+
export default class TableConditionQuery<Entity, Table extends QueryTable<Entity, any>> {
|
|
6
|
+
protected _queryProcessor: QueryProcessor;
|
|
7
|
+
protected _table: Table;
|
|
8
|
+
protected _conditions: QueryCondition<Table>[];
|
|
9
|
+
constructor(_queryProcessor: QueryProcessor, _table: Table, _conditions: QueryCondition<Table>[]);
|
|
10
|
+
protected _columns: QueryColumn<Table, any>[];
|
|
11
|
+
protected _action: QueryAction;
|
|
12
|
+
protected _entity: Entity | Partial<Entity>;
|
|
13
|
+
update(entity: Partial<Entity>): Promise<number>;
|
|
14
|
+
delete(): Promise<number>;
|
|
15
|
+
count(): Promise<number>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class TableConditionQuery {
|
|
4
|
+
_queryProcessor;
|
|
5
|
+
_table;
|
|
6
|
+
_conditions;
|
|
7
|
+
constructor(_queryProcessor, _table, _conditions) {
|
|
8
|
+
this._queryProcessor = _queryProcessor;
|
|
9
|
+
this._table = _table;
|
|
10
|
+
this._conditions = _conditions;
|
|
11
|
+
}
|
|
12
|
+
_columns = [];
|
|
13
|
+
_action;
|
|
14
|
+
_entity;
|
|
15
|
+
update(entity) {
|
|
16
|
+
this._entity = entity;
|
|
17
|
+
this._action = 'update';
|
|
18
|
+
return this._queryProcessor(this);
|
|
19
|
+
}
|
|
20
|
+
delete() {
|
|
21
|
+
this._action = 'delete';
|
|
22
|
+
return this._queryProcessor(this);
|
|
23
|
+
}
|
|
24
|
+
count() {
|
|
25
|
+
this._columns = [this._table.$all.count()];
|
|
26
|
+
this._action = 'select';
|
|
27
|
+
return this._queryProcessor(this).then((rows) => rows[0]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = TableConditionQuery;
|
|
31
|
+
//# sourceMappingURL=table-condition-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-condition-query.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAMA,MAAqB,mBAAmB;IAGtB;IACA;IACA;IAHd,YACc,eAA+B,EAC/B,MAAa,EACb,WAAoC;QAFpC,oBAAe,GAAf,eAAe,CAAgB;QAC/B,WAAM,GAAN,MAAM,CAAO;QACb,gBAAW,GAAX,WAAW,CAAyB;IAC/C,CAAC;IAEM,QAAQ,GAA8B,EAAE,CAAC;IACzC,OAAO,CAAc;IACrB,OAAO,CAA2B;IAE5C,MAAM,CAAC,MAAuB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM;QACF,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;CACJ;AA5BD,sCA4BC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import QueryTable from "../query-table";
|
|
2
|
+
import TableConditionQuery from "./table-condition-query";
|
|
3
|
+
import QueryCondition from "../condition/query-condition";
|
|
4
|
+
import QueryColumn from "../column/query-column";
|
|
5
|
+
import { QueryProcessor, QueryAction } from "../helpers/internal-types";
|
|
6
|
+
export default class TableQuery<Entity, Id, Table extends QueryTable<Entity, Id>> {
|
|
7
|
+
protected _queryProcessor: QueryProcessor;
|
|
8
|
+
protected _table: Table;
|
|
9
|
+
constructor(_queryProcessor: QueryProcessor, _table: Table);
|
|
10
|
+
protected _entity: Entity | Entity[] | Partial<Entity>;
|
|
11
|
+
protected _action: QueryAction;
|
|
12
|
+
protected _columns: QueryColumn<Table, any>[];
|
|
13
|
+
where(...conditions: QueryCondition<Table>[]): TableConditionQuery<Entity, Table>;
|
|
14
|
+
insert(entity: Entity): Promise<any>;
|
|
15
|
+
insert(entities: Entity[]): Promise<void>;
|
|
16
|
+
deleteAll(): Promise<number>;
|
|
17
|
+
updateAll(entity: Partial<Entity>): Promise<number>;
|
|
18
|
+
countAll(): Promise<number>;
|
|
19
|
+
delete(id: Id): Promise<boolean>;
|
|
20
|
+
update(id: Id, entity: Partial<Entity>): Promise<boolean>;
|
|
21
|
+
get(id: Id): Promise<Entity | undefined>;
|
|
22
|
+
_whereId(id: Id): TableConditionQuery<Entity, Table>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const table_condition_query_1 = require("./table-condition-query");
|
|
4
|
+
const value_column_1 = require("../column/value-column");
|
|
5
|
+
class TableQuery {
|
|
6
|
+
_queryProcessor;
|
|
7
|
+
_table;
|
|
8
|
+
constructor(_queryProcessor, _table) {
|
|
9
|
+
this._queryProcessor = _queryProcessor;
|
|
10
|
+
this._table = _table;
|
|
11
|
+
}
|
|
12
|
+
_entity;
|
|
13
|
+
_action;
|
|
14
|
+
_columns = [];
|
|
15
|
+
where(...conditions) {
|
|
16
|
+
return new table_condition_query_1.default(this._queryProcessor, this._table, conditions);
|
|
17
|
+
}
|
|
18
|
+
insert(param) {
|
|
19
|
+
this._entity = param;
|
|
20
|
+
this._action = 'insert';
|
|
21
|
+
return this._queryProcessor(this);
|
|
22
|
+
}
|
|
23
|
+
deleteAll() {
|
|
24
|
+
this._action = 'delete';
|
|
25
|
+
return this._queryProcessor(this);
|
|
26
|
+
}
|
|
27
|
+
updateAll(entity) {
|
|
28
|
+
this._entity = entity;
|
|
29
|
+
this._action = 'update';
|
|
30
|
+
return this._queryProcessor(this);
|
|
31
|
+
}
|
|
32
|
+
countAll() {
|
|
33
|
+
this._columns = [this._table.$all.count()];
|
|
34
|
+
this._action = 'select';
|
|
35
|
+
return this._queryProcessor(this).then((rows) => rows[0]);
|
|
36
|
+
}
|
|
37
|
+
delete(id) {
|
|
38
|
+
return this._whereId(id).delete().then(count => count > 0);
|
|
39
|
+
}
|
|
40
|
+
update(id, entity) {
|
|
41
|
+
return this._whereId(id).update(entity).then(count => count > 0);
|
|
42
|
+
}
|
|
43
|
+
get(id) {
|
|
44
|
+
let query = this._whereId(id);
|
|
45
|
+
return this._queryProcessor({ _action: 'select', ...query })
|
|
46
|
+
.then((rows) => rows[0]);
|
|
47
|
+
}
|
|
48
|
+
_whereId(id) {
|
|
49
|
+
// TODO remove assertions if $id typing is fixed
|
|
50
|
+
let $id = this._table.$id;
|
|
51
|
+
if ($id instanceof value_column_1.default) {
|
|
52
|
+
return this.where($id.eq(id));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return this.where(...Object.keys($id).map(key => this._table[key].eq(id[key])));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = TableQuery;
|
|
60
|
+
//# sourceMappingURL=table-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-query.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AACA,mEAA0D;AAE1D,yDAAiD;AAKjD,MAAqB,UAAU;IAGb;IACA;IAFd,YACc,eAA+B,EAC/B,MAAa;QADb,oBAAe,GAAf,eAAe,CAAgB;QAC/B,WAAM,GAAN,MAAM,CAAO;IACxB,CAAC;IAEM,OAAO,CAAsC;IAC7C,OAAO,CAAc;IACrB,QAAQ,GAA8B,EAAE,CAAC;IAEnD,KAAK,CAAC,GAAG,UAAmC;QACxC,OAAO,IAAI,+BAAmB,CAAgB,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjG,CAAC;IAID,MAAM,CAAC,KAAU;QACb,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,SAAS;QACL,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,SAAS,CAAC,MAAuB;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAW,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,EAAM;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,EAAM,EAAE,MAAuB;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,GAAG,CAAC,EAAM;QACN,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,CAAC;aACvD,IAAI,CAAC,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,QAAQ,CAAC,EAAM;QACX,gDAAgD;QAChD,IAAI,GAAG,GAAI,IAAI,CAAC,MAAc,CAAC,GAAG,CAAC;QACnC,IAAI,GAAG,YAAY,sBAAW,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAG,IAAI,CAAC,MAAc,CAAC,GAAG,CAA6B,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAQ,CAAC,CAAC,CAAC,CAAC;QAC1I,CAAC;IACL,CAAC;CACJ;AA/DD,6BA+DC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import QueryTable from './query-table';
|
|
2
|
+
import SelectQuery from './query/select-query';
|
|
3
|
+
import { QueryProcessor } from "./helpers/internal-types";
|
|
4
|
+
import JoinedTables from "./join/joined-tables";
|
|
5
|
+
import TableQuery from "./query/table-query";
|
|
6
|
+
export default class QuerySource {
|
|
7
|
+
protected _queryProcessor: QueryProcessor;
|
|
8
|
+
constructor(_queryProcessor: QueryProcessor);
|
|
9
|
+
from<Entity, Table1 extends QueryTable<Entity, any>>(table1: Table1 & QueryTable<Entity, any>): SelectQuery<Entity, Table1>;
|
|
10
|
+
from<Tables extends QueryTable<any, any>>(tables: JoinedTables<Tables>): SelectQuery<any, Tables>;
|
|
11
|
+
from<Table1 extends QueryTable<any, any>, Table2 extends QueryTable<any, any>>(table1: Table1, table2: Table2): SelectQuery<any, Table1 | Table2>;
|
|
12
|
+
from<Table1 extends QueryTable<any, any>, Table2 extends QueryTable<any, any>, Table3 extends QueryTable<any, any>>(table1: Table1, table2: Table2, table3: Table3): SelectQuery<any, Table1 | Table2 | Table3>;
|
|
13
|
+
table<Entity, Id, Table extends QueryTable<Entity, Id>>(table: Table & QueryTable<Entity, Id>): TableQuery<Entity, Id, Table>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const select_query_1 = require("./query/select-query");
|
|
4
|
+
const table_query_1 = require("./query/table-query");
|
|
5
|
+
class QuerySource {
|
|
6
|
+
_queryProcessor;
|
|
7
|
+
constructor(_queryProcessor) {
|
|
8
|
+
this._queryProcessor = _queryProcessor;
|
|
9
|
+
}
|
|
10
|
+
from(table1, table2, table3) {
|
|
11
|
+
if (table3 != null)
|
|
12
|
+
return new select_query_1.default(this._queryProcessor, [table1, table2, table3]);
|
|
13
|
+
else if (table2 != null)
|
|
14
|
+
return new select_query_1.default(this._queryProcessor, [table1, table2]);
|
|
15
|
+
return new select_query_1.default(this._queryProcessor, [table1]);
|
|
16
|
+
}
|
|
17
|
+
table(table) {
|
|
18
|
+
return new table_query_1.default(this._queryProcessor, table);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = QuerySource;
|
|
22
|
+
//# sourceMappingURL=query-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-source.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AACA,uDAA+C;AAG/C,qDAA6C;AAG7C,MAAqB,WAAW;IAEN;IAAtB,YAAsB,eAA+B;QAA/B,oBAAe,GAAf,eAAe,CAAgB;IAAG,CAAC;IAMzD,IAAI,CAAwH,MAAW,EAAE,MAAY,EAAE,MAAY;QAC/J,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,IAAI,sBAAW,CAAgC,IAAI,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;aACrH,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,IAAI,sBAAW,CAAuB,IAAI,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9G,OAAO,IAAI,sBAAW,CAAiB,IAAI,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAmD,KAAqC;QACzF,OAAO,IAAI,qBAAU,CAAoB,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC;CACJ;AAjBD,8BAiBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BasicColumn from "./column/basic-column";
|
|
2
|
+
import GenericsHelper from "./helpers/generics-helper";
|
|
3
|
+
import JoinedTablesChain from "./join/joined-tables-chain";
|
|
4
|
+
declare abstract class QueryTable<Entity, Id> {
|
|
5
|
+
protected _$name: string;
|
|
6
|
+
constructor(_$name: string);
|
|
7
|
+
protected _$type: GenericsHelper<Entity>;
|
|
8
|
+
protected _$idType: GenericsHelper<Id>;
|
|
9
|
+
$all: BasicColumn<this, Entity>;
|
|
10
|
+
innerJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<this | JoinTable>;
|
|
11
|
+
leftJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<this | JoinTable>;
|
|
12
|
+
rightJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<this | JoinTable>;
|
|
13
|
+
fullJoin<JoinTable extends QueryTable<any, any>>(table: JoinTable): JoinedTablesChain<this | JoinTable>;
|
|
14
|
+
}
|
|
15
|
+
export default QueryTable;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const basic_column_1 = require("./column/basic-column");
|
|
4
|
+
const joined_tables_chain_1 = require("./join/joined-tables-chain");
|
|
5
|
+
class QueryTable {
|
|
6
|
+
_$name;
|
|
7
|
+
constructor(_$name) {
|
|
8
|
+
this._$name = _$name;
|
|
9
|
+
}
|
|
10
|
+
_$type;
|
|
11
|
+
_$idType;
|
|
12
|
+
// abstract readonly $id; // FIXME I got a dozen incomprehensible type errors
|
|
13
|
+
$all = new basic_column_1.default(this, '*');
|
|
14
|
+
innerJoin(table) {
|
|
15
|
+
return new joined_tables_chain_1.default(table, 'inner', this);
|
|
16
|
+
}
|
|
17
|
+
leftJoin(table) {
|
|
18
|
+
return new joined_tables_chain_1.default(table, 'left', this);
|
|
19
|
+
}
|
|
20
|
+
rightJoin(table) {
|
|
21
|
+
return new joined_tables_chain_1.default(table, 'right', this);
|
|
22
|
+
}
|
|
23
|
+
fullJoin(table) {
|
|
24
|
+
return new joined_tables_chain_1.default(table, 'full', this);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = QueryTable;
|
|
28
|
+
//# sourceMappingURL=query-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-table.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAAA,wDAAgD;AAEhD,oEAA2D;AAG3D,MAAe,UAAU;IAEC;IAAtB,YAAsB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE9B,MAAM,CAAyB;IAC/B,QAAQ,CAAqB;IAEvC,6EAA6E;IAE7E,IAAI,GAAG,IAAI,sBAAW,CAAe,IAAI,EAAE,GAAG,CAAC,CAAC;IAEhD,SAAS,CAAyC,KAAgB;QAC9D,OAAO,IAAI,6BAAiB,CAAmB,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,QAAQ,CAAyC,KAAgB;QAC7D,OAAO,IAAI,6BAAiB,CAAmB,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IAED,SAAS,CAAyC,KAAgB;QAC9D,OAAO,IAAI,6BAAiB,CAAmB,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,QAAQ,CAAyC,KAAgB;QAC7D,OAAO,IAAI,6BAAiB,CAAmB,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;CACJ;AAED,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const query_source_1 = require("../builder/query-source");
|
|
4
|
+
const query_processor_1 = require("./query-processor");
|
|
5
|
+
class MySqlQuerySource extends query_source_1.default {
|
|
6
|
+
constructor(client, options = {}) {
|
|
7
|
+
super((0, query_processor_1.createQueryProcessor)(client, options, 'mysql'));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = MySqlQuerySource;
|
|
11
|
+
//# sourceMappingURL=mysql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAAA,0DAAkD;AAClD,uDAA8E;AAE9E,MAAqB,gBAAiB,SAAQ,sBAAW;IAErD,YAAY,MAAW,EAAE,UAAiC,EAAE;QACxD,KAAK,CAAC,IAAA,sCAAoB,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;CACJ;AALD,mCAKC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const query_source_1 = require("../builder/query-source");
|
|
4
|
+
const query_processor_1 = require("./query-processor");
|
|
5
|
+
class PgQuerySource extends query_source_1.default {
|
|
6
|
+
constructor(client, options = {}) {
|
|
7
|
+
super((0, query_processor_1.createQueryProcessor)(client, options, 'pg'));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = PgQuerySource;
|
|
11
|
+
//# sourceMappingURL=pg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAAA,0DAAkD;AAClD,uDAA8E;AAE9E,MAAqB,aAAc,SAAQ,sBAAW;IAElD,YAAY,MAAW,EAAE,UAAiC,EAAE;QACxD,KAAK,CAAC,IAAA,sCAAoB,EAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;CACJ;AALD,gCAKC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QueryEngine } from '../converter/types';
|
|
2
|
+
import { QueryProcessor } from '../builder/helpers/internal-types';
|
|
3
|
+
export interface QueryProcessorOptions {
|
|
4
|
+
lineBreaks?: boolean;
|
|
5
|
+
parameterized?: boolean;
|
|
6
|
+
logging?: boolean;
|
|
7
|
+
logger?: (sql: string, params?: any[]) => void;
|
|
8
|
+
identifierQuote?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createQueryProcessor(client: any, _options?: QueryProcessorOptions, engine?: QueryEngine): QueryProcessor;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createQueryProcessor = createQueryProcessor;
|
|
4
|
+
const lib_prod_1 = require("ng2-logger/lib-prod");
|
|
5
|
+
const parameterized_converter_1 = require("../converter/parameterized-converter");
|
|
6
|
+
const sql_converter_1 = require("../converter/sql-converter");
|
|
7
|
+
const log = lib_prod_1.Log.create('query processor');
|
|
8
|
+
const DEFAULT_OPTIONS = {
|
|
9
|
+
lineBreaks: false,
|
|
10
|
+
parameterized: true,
|
|
11
|
+
logging: true,
|
|
12
|
+
identifierQuote: '"'
|
|
13
|
+
};
|
|
14
|
+
function mySqlTypeCast(field, next) {
|
|
15
|
+
if (field.type == 'TINY' && field.length == 1) { // Boolean
|
|
16
|
+
let value = field.string();
|
|
17
|
+
if (value == '1')
|
|
18
|
+
return true;
|
|
19
|
+
if (value == '0')
|
|
20
|
+
return false;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
else if (field.type == 'JSON') {
|
|
24
|
+
let value = field.string();
|
|
25
|
+
return value == null ? null : JSON.parse(value);
|
|
26
|
+
}
|
|
27
|
+
return next();
|
|
28
|
+
}
|
|
29
|
+
function createQueryProcessor(client, _options = {}, engine = 'pg') {
|
|
30
|
+
let options = Object.assign({}, DEFAULT_OPTIONS, _options);
|
|
31
|
+
let queryOptions = {
|
|
32
|
+
lineBreak: options.lineBreaks ? '\n' : ' ',
|
|
33
|
+
nameEscape: _options.identifierQuote || (engine === 'mysql' ? '`' : '"')
|
|
34
|
+
};
|
|
35
|
+
// function processSql(query: any, sql: string, params: any[] | undefined, callback: any): Promise<any> {
|
|
36
|
+
// if (options.logging) log.i(sql);
|
|
37
|
+
// if (options.logger) options.logger(sql, params);
|
|
38
|
+
// return new Promise((resolve, reject) => {
|
|
39
|
+
// callback(sql, params, (err: any, result: any) => {
|
|
40
|
+
// if (err) reject(err);
|
|
41
|
+
// else resolve(convertResult(query, result, engine));
|
|
42
|
+
// });
|
|
43
|
+
// });
|
|
44
|
+
// }
|
|
45
|
+
// function executeSql(sql: string, params: any[] | undefined, cb: any) {
|
|
46
|
+
// if (engine === 'pg') {
|
|
47
|
+
// client.query(sql, params || cb, params ? cb : undefined);
|
|
48
|
+
// } else if (engine === 'mysql') {
|
|
49
|
+
// client.query({
|
|
50
|
+
// sql,
|
|
51
|
+
// values: params,
|
|
52
|
+
// typeCast: mySqlTypeCast
|
|
53
|
+
// }, cb);
|
|
54
|
+
// } else throw new Error('Unknown DB engine: ' + engine);
|
|
55
|
+
// }
|
|
56
|
+
return (query) => {
|
|
57
|
+
if (options.parameterized) {
|
|
58
|
+
let { sql, params } = (0, parameterized_converter_1.convertQueryToParameterizedSQL)(query, queryOptions, engine);
|
|
59
|
+
// if (Helpers.isWebSQL || Helpers.isNode) {
|
|
60
|
+
return client.query(sql, params);
|
|
61
|
+
// }
|
|
62
|
+
// return processSql(query, sql, params, (sql: string, params: any[], cb: any) => executeSql(sql, params, cb));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
let sql = (0, sql_converter_1.convertQueryToSQL)(query, queryOptions, engine);
|
|
66
|
+
// if (Helpers.isWebSQL || Helpers.isNode) {
|
|
67
|
+
return client.query(sql, undefined);
|
|
68
|
+
// }
|
|
69
|
+
// return processSql(query, sql, undefined, (sql: string, params: undefined, cb: any) => executeSql(sql, undefined, cb));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=query-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-processor.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;AAwCA,oDAgDC;AAxFD,kDAAiD;AACjD,kFAAsF;AACtF,8DAA+D;AAM/D,MAAM,GAAG,GAAG,cAAG,CAAC,MAAM,CAAC,iBAAiB,CAEvC,CAAA;AAUD,MAAM,eAAe,GAA0B;IAC7C,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,GAAG;CACrB,CAAC;AAEF,SAAS,aAAa,CAAC,KAAU,EAAE,IAAS;IAC1C,IAAI,KAAK,CAAC,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU;QACzD,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,IAAI,GAAG;YAAE,OAAO,IAAI,CAAC;QAC9B,IAAI,KAAK,IAAI,GAAG;YAAE,OAAO,KAAK,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,IAAI,MAAM,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAW,EAAE,WAAkC,EAAE,EAAE,SAAsB,IAAI;IAEhH,IAAI,OAAO,GAA0B,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IAElF,IAAI,YAAY,GAAqB;QACnC,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;QAC1C,UAAU,EAAE,QAAQ,CAAC,eAAe,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;KACzE,CAAC;IAEF,yGAAyG;IACzG,qCAAqC;IACrC,qDAAqD;IAErD,8CAA8C;IAC9C,yDAAyD;IACzD,8BAA8B;IAC9B,4DAA4D;IAC5D,UAAU;IACV,QAAQ;IACR,IAAI;IAEJ,yEAAyE;IACzE,2BAA2B;IAC3B,gEAAgE;IAChE,qCAAqC;IACrC,qBAAqB;IACrB,aAAa;IACb,wBAAwB;IACxB,gCAAgC;IAChC,cAAc;IACd,4DAA4D;IAC5D,IAAI;IAEJ,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC1B,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,wDAA8B,EAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YAClF,4CAA4C;YAC5C,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACjC,IAAI;YACJ,+GAA+G;QACjH,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,GAAG,IAAA,iCAAiB,EAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YACzD,4CAA4C;YAC5C,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACpC,IAAI;YACJ,yHAAyH;QAC3H,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|