drizzle-orm 0.9.18 → 0.10.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/README.md +39 -9
- package/builders/aggregators/abstractAggregator.d.ts +4 -2
- package/builders/aggregators/abstractAggregator.js +11 -4
- package/builders/aggregators/selectAggregator.d.ts +12 -4
- package/builders/aggregators/selectAggregator.js +29 -12
- package/builders/highLvlBuilders/abstractRequestBuilder.d.ts +10 -4
- package/builders/highLvlBuilders/abstractRequestBuilder.js +14 -3
- package/builders/highLvlBuilders/deleteRequestBuilder.d.ts +4 -2
- package/builders/highLvlBuilders/insertRequestBuilder.d.ts +4 -2
- package/builders/highLvlBuilders/insertRequestBuilder.js +1 -0
- package/builders/highLvlBuilders/selectRequestBuilder.d.ts +21 -16
- package/builders/highLvlBuilders/selectRequestBuilder.js +22 -11
- package/builders/highLvlBuilders/updateRequestBuilder.d.ts +4 -2
- package/builders/joinBuilders/builders/abstractJoinBuilder.d.ts +16 -3
- package/builders/joinBuilders/builders/abstractJoinBuilder.js +19 -2
- package/builders/joinBuilders/builders/selectWithFiveJoins.d.ts +16 -4
- package/builders/joinBuilders/builders/selectWithFiveJoins.js +19 -10
- package/builders/joinBuilders/builders/selectWithFourJoins.d.ts +31 -12
- package/builders/joinBuilders/builders/selectWithFourJoins.js +31 -21
- package/builders/joinBuilders/builders/selectWithJoin.d.ts +28 -12
- package/builders/joinBuilders/builders/selectWithJoin.js +23 -18
- package/builders/joinBuilders/builders/selectWithThreeJoins.d.ts +30 -12
- package/builders/joinBuilders/builders/selectWithThreeJoins.js +28 -20
- package/builders/joinBuilders/builders/selectWithTwoJoins.d.ts +29 -12
- package/builders/joinBuilders/builders/selectWithTwoJoins.js +25 -19
- package/builders/joinBuilders/responses/selectResponseFiveJoins.d.ts +14 -13
- package/builders/joinBuilders/responses/selectResponseFourJoins.d.ts +13 -12
- package/builders/joinBuilders/responses/selectResponseThreeJoins.d.ts +8 -7
- package/builders/joinBuilders/responses/selectResponseTwoJoins.d.ts +8 -7
- package/builders/joinBuilders/responses/selectResponseWithJoin.d.ts +8 -7
- package/builders/lowLvlBuilders/selects/select.d.ts +5 -1
- package/builders/lowLvlBuilders/selects/select.js +3 -2
- package/builders/lowLvlBuilders/selects/selectFrom.d.ts +9 -3
- package/builders/lowLvlBuilders/selects/selectJoined.d.ts +8 -2
- package/builders/lowLvlBuilders/selects/whereSelect.d.ts +1 -1
- package/builders/requestBuilders/updates/static.d.ts +2 -2
- package/builders/requestBuilders/where/const.js +3 -0
- package/builders/requestBuilders/where/constArray.js +3 -0
- package/builders/requestBuilders/where/static.d.ts +9 -9
- package/columns/column.d.ts +24 -20
- package/columns/column.js +8 -1
- package/docs/cases/simple_delete.js +1 -1
- package/docs/cases/simple_insert.js +9 -4
- package/docs/cases/simple_join.js +20 -6
- package/docs/cases/simple_select.js +15 -9
- package/docs/cases/simple_update.js +1 -1
- package/docs/tables/citiesTable.d.ts +5 -5
- package/docs/tables/citiesTable.js +1 -2
- package/docs/tables/userGroupsTable.d.ts +3 -3
- package/docs/tables/usersTable.d.ts +9 -10
- package/docs/tables/usersTable.js +2 -2
- package/docs/tables/usersToUserGroups.d.ts +2 -2
- package/mappers/responseMapper.d.ts +4 -1
- package/mappers/responseMapper.js +18 -6
- package/migrator/migrator.js +6 -5
- package/package.json +1 -1
- package/serializer/serializer.js +14 -1
- package/tables/abstractTable.d.ts +19 -20
- package/tables/abstractTable.js +4 -3
- package/tables/inferTypes.d.ts +14 -0
- package/tables/migrationsTable.d.ts +3 -3
- package/test.js +71 -16
|
@@ -3,21 +3,33 @@ import { AbstractColumn } from '../../../columns/column';
|
|
|
3
3
|
import ColumnType from '../../../columns/types/columnType';
|
|
4
4
|
import { ISession } from '../../../db/session';
|
|
5
5
|
import { AbstractTable } from '../../../tables';
|
|
6
|
+
import { PartialFor } from '../../../tables/inferTypes';
|
|
6
7
|
import Order from '../../highLvlBuilders/order';
|
|
7
8
|
import Expr from '../../requestBuilders/where/where';
|
|
8
9
|
import Join from '../join';
|
|
9
10
|
import SelectResponseFiveJoins from '../responses/selectResponseFiveJoins';
|
|
10
11
|
import AbstractJoined from './abstractJoinBuilder';
|
|
11
|
-
export default class SelectTRBWithFiveJoins<TTable extends AbstractTable<TTable>, TTable1, TTable2, TTable3, TTable4, TTable5> extends AbstractJoined<TTable, SelectResponseFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, TTable5
|
|
12
|
+
export default class SelectTRBWithFiveJoins<TTable extends AbstractTable<TTable>, TTable1 extends AbstractTable<TTable1>, TTable2 extends AbstractTable<TTable2>, TTable3 extends AbstractTable<TTable3>, TTable4 extends AbstractTable<TTable4>, TTable5 extends AbstractTable<TTable5>, TPartial extends PartialFor<TTable> = {}, TPartial1 extends PartialFor<TTable1> = {}, TPartial2 extends PartialFor<TTable2> = {}, TPartial3 extends PartialFor<TTable3> = {}, TPartial4 extends PartialFor<TTable4> = {}, TPartial5 extends PartialFor<TTable5> = {}> extends AbstractJoined<TTable, SelectResponseFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, TTable5, TPartial, TPartial1, TPartial2, TPartial3, TPartial4, TPartial5>, TPartial> {
|
|
12
13
|
private _join1;
|
|
13
14
|
private _join2;
|
|
14
15
|
private _join3;
|
|
15
16
|
private _join4;
|
|
16
17
|
private _join5;
|
|
18
|
+
private _joinedPartial?;
|
|
19
|
+
private _joinedPartial1?;
|
|
20
|
+
private _joinedPartial2?;
|
|
21
|
+
private _joinedPartial3?;
|
|
22
|
+
private _joinedPartial4?;
|
|
17
23
|
constructor(table: TTable, session: ISession, filter: Expr, join1: Join<TTable1>, join2: Join<TTable2>, join3: Join<TTable3>, join4: Join<TTable4>, join5: Join<TTable5>, props: {
|
|
18
24
|
limit?: number;
|
|
19
25
|
offset?: number;
|
|
20
|
-
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean
|
|
21
|
-
protected joins():
|
|
22
|
-
|
|
26
|
+
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean>, tablePartial?: TPartial, joinedPartial?: TPartial1, joinedPartial1?: TPartial2, joinedPartial2?: TPartial3, joinedPartial3?: TPartial4, joinedPartial4?: TPartial5);
|
|
27
|
+
protected joins(): Array<{
|
|
28
|
+
join: Join<any>;
|
|
29
|
+
partial?: {
|
|
30
|
+
[name: string]: AbstractColumn<ColumnType<any>, boolean, boolean, any>;
|
|
31
|
+
};
|
|
32
|
+
id?: number;
|
|
33
|
+
}>;
|
|
34
|
+
protected mapResponse(result: QueryResult<any>): SelectResponseFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, TTable5, TPartial, TPartial1, TPartial2, TPartial3, TPartial4, TPartial5>;
|
|
23
35
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const responseMapper_1 = require("../../../mappers/responseMapper");
|
|
4
3
|
const selectResponseFiveJoins_1 = require("../responses/selectResponseFiveJoins");
|
|
5
4
|
const abstractJoinBuilder_1 = require("./abstractJoinBuilder");
|
|
6
5
|
class SelectTRBWithFiveJoins extends abstractJoinBuilder_1.default {
|
|
7
|
-
constructor(table, session, filter, join1, join2, join3, join4, join5, props, orderBy, order, distinct) {
|
|
8
|
-
super(table, filter, session, props, orderBy, order, distinct);
|
|
6
|
+
constructor(table, session, filter, join1, join2, join3, join4, join5, props, orderBy, order, distinct, tablePartial, joinedPartial, joinedPartial1, joinedPartial2, joinedPartial3, joinedPartial4) {
|
|
7
|
+
super(table, filter, session, props, orderBy, order, distinct, tablePartial);
|
|
9
8
|
this._join1 = join1;
|
|
10
9
|
this._join2 = join2;
|
|
11
10
|
this._join3 = join3;
|
|
12
11
|
this._join4 = join4;
|
|
13
12
|
this._join5 = join5;
|
|
13
|
+
this._joinedPartial = joinedPartial;
|
|
14
|
+
this._joinedPartial1 = joinedPartial1;
|
|
15
|
+
this._joinedPartial2 = joinedPartial2;
|
|
16
|
+
this._joinedPartial3 = joinedPartial3;
|
|
17
|
+
this._joinedPartial4 = joinedPartial4;
|
|
14
18
|
}
|
|
15
19
|
joins() {
|
|
16
|
-
return [this._join1,
|
|
20
|
+
return [{ join: this._join1, partial: this._joinedPartial, id: 1 },
|
|
21
|
+
{ join: this._join2, partial: this._joinedPartial1, id: 2 },
|
|
22
|
+
{ join: this._join3, partial: this._joinedPartial2, id: 3 },
|
|
23
|
+
{ join: this._join4, partial: this._joinedPartial3, id: 4 },
|
|
24
|
+
{ join: this._join5, partial: this._joinedPartial4, id: 5 }];
|
|
17
25
|
}
|
|
18
26
|
mapResponse(result) {
|
|
19
27
|
const parent = this._join1.mappedServiceToDb;
|
|
@@ -21,12 +29,13 @@ class SelectTRBWithFiveJoins extends abstractJoinBuilder_1.default {
|
|
|
21
29
|
const parentThree = this._join3.mappedServiceToDb;
|
|
22
30
|
const parentFour = this._join4.mappedServiceToDb;
|
|
23
31
|
const parentFive = this._join5.mappedServiceToDb;
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
32
|
+
// TODO map ids for join properly
|
|
33
|
+
const response = this.fullOrPartial(this._table.mapServiceToDb(), result, this._partial);
|
|
34
|
+
const objects = this.fullOrPartial(parent, result, this._joinedPartial, 1);
|
|
35
|
+
const objectsTwo = this.fullOrPartial(parentTwo, result, this._joinedPartial1, 2);
|
|
36
|
+
const objectsThree = this.fullOrPartial(parentThree, result, this._joinedPartial2, 3);
|
|
37
|
+
const objectsFour = this.fullOrPartial(parentFour, result, this._joinedPartial3, 4);
|
|
38
|
+
const objectsFive = this.fullOrPartial(parentFive, result, this._joinedPartial4, 5);
|
|
30
39
|
return new selectResponseFiveJoins_1.default(response, objects, objectsTwo, objectsThree, objectsFour, objectsFive);
|
|
31
40
|
}
|
|
32
41
|
}
|
|
@@ -4,33 +4,52 @@ import ColumnType from '../../../columns/types/columnType';
|
|
|
4
4
|
import DB from '../../../db/db';
|
|
5
5
|
import { ISession } from '../../../db/session';
|
|
6
6
|
import { AbstractTable } from '../../../tables';
|
|
7
|
+
import { CheckFiveTypes, PartialFor } from '../../../tables/inferTypes';
|
|
7
8
|
import Order from '../../highLvlBuilders/order';
|
|
8
9
|
import Expr from '../../requestBuilders/where/where';
|
|
9
10
|
import Join from '../join';
|
|
10
11
|
import SelectResponseFourJoins from '../responses/selectResponseFourJoins';
|
|
11
12
|
import AbstractJoined from './abstractJoinBuilder';
|
|
12
13
|
import SelectTRBWithFiveJoins from './selectWithFiveJoins';
|
|
13
|
-
export default class SelectTRBWithFourJoins<TTable extends AbstractTable<TTable>, TTable1, TTable2, TTable3, TTable4> extends AbstractJoined<TTable, SelectResponseFourJoins<TTable, TTable1, TTable2, TTable3, TTable4
|
|
14
|
+
export default class SelectTRBWithFourJoins<TTable extends AbstractTable<TTable>, TTable1 extends AbstractTable<TTable1>, TTable2 extends AbstractTable<TTable2>, TTable3 extends AbstractTable<TTable3>, TTable4 extends AbstractTable<TTable4>, TPartial extends PartialFor<TTable> = {}, TPartial1 extends PartialFor<TTable1> = {}, TPartial2 extends PartialFor<TTable2> = {}, TPartial3 extends PartialFor<TTable3> = {}, TPartial4 extends PartialFor<TTable4> = {}> extends AbstractJoined<TTable, SelectResponseFourJoins<TTable, TTable1, TTable2, TTable3, TTable4, TPartial, TPartial1, TPartial2, TPartial3, TPartial4>, TPartial> {
|
|
14
15
|
private _join1;
|
|
15
16
|
private _join2;
|
|
16
17
|
private _join3;
|
|
17
18
|
private _join4;
|
|
19
|
+
private _joinedPartial?;
|
|
20
|
+
private _joinedPartial1?;
|
|
21
|
+
private _joinedPartial2?;
|
|
22
|
+
private _joinedPartial3?;
|
|
18
23
|
constructor(table: TTable, session: ISession, filter: Expr, join1: Join<TTable1>, join2: Join<TTable2>, join3: Join<TTable3>, join4: Join<TTable4>, props: {
|
|
19
24
|
limit?: number;
|
|
20
25
|
offset?: number;
|
|
21
|
-
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean
|
|
22
|
-
innerJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
26
|
+
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean>, tablePartial?: TPartial, joinedPartial?: TPartial1, joinedPartial1?: TPartial2, joinedPartial2?: TPartial3, joinedPartial3?: TPartial4);
|
|
27
|
+
innerJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
28
|
+
new (db: DB): InputTable;
|
|
29
|
+
}, table: {
|
|
23
30
|
new (db: DB): IToTable;
|
|
24
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
25
|
-
leftJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
31
|
+
}, from: (table: CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>) => AbstractColumn<TColumn, boolean, boolean, CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean>, partial?: IToPartial): SelectTRBWithFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, IToTable, TPartial, TPartial1, TPartial2, TPartial3, TPartial4, IToPartial>;
|
|
32
|
+
leftJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
33
|
+
new (db: DB): InputTable;
|
|
34
|
+
}, table: {
|
|
26
35
|
new (db: DB): IToTable;
|
|
27
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
28
|
-
rightJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
36
|
+
}, from: (table: CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>) => AbstractColumn<TColumn, boolean, boolean, CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean>, partial?: IToPartial): SelectTRBWithFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, IToTable, TPartial, TPartial1, TPartial2, TPartial3, TPartial4, IToPartial>;
|
|
37
|
+
rightJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
38
|
+
new (db: DB): InputTable;
|
|
39
|
+
}, table: {
|
|
29
40
|
new (db: DB): IToTable;
|
|
30
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
31
|
-
fullJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
41
|
+
}, from: (table: CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>) => AbstractColumn<TColumn, boolean, boolean, CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean>, partial?: IToPartial): SelectTRBWithFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, IToTable, TPartial, TPartial1, TPartial2, TPartial3, TPartial4, IToPartial>;
|
|
42
|
+
fullJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
43
|
+
new (db: DB): InputTable;
|
|
44
|
+
}, table: {
|
|
32
45
|
new (db: DB): IToTable;
|
|
33
|
-
}, from: (table: TTable) => AbstractColumn<TColumn
|
|
34
|
-
protected joins():
|
|
35
|
-
|
|
46
|
+
}, from: (table: CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>) => AbstractColumn<TColumn, boolean, boolean, CheckFiveTypes<InputTable, TTable, TTable1, TTable2, TTable3, TTable4>>, to: (table: IToTable) => AbstractColumn<TColumn>, partial?: IToPartial): SelectTRBWithFiveJoins<TTable, TTable1, TTable2, TTable3, TTable4, IToTable, TPartial, TPartial1, TPartial2, TPartial3, TPartial4, IToPartial>;
|
|
47
|
+
protected joins(): Array<{
|
|
48
|
+
join: Join<any>;
|
|
49
|
+
partial?: {
|
|
50
|
+
[name: string]: AbstractColumn<ColumnType<any>, boolean, boolean, any>;
|
|
51
|
+
};
|
|
52
|
+
id?: number;
|
|
53
|
+
}>;
|
|
54
|
+
protected mapResponse(result: QueryResult<any>): SelectResponseFourJoins<TTable, TTable1, TTable2, TTable3, TTable4, TPartial, TPartial1, TPartial2, TPartial3, TPartial4>;
|
|
36
55
|
}
|
|
@@ -1,64 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const responseMapper_1 = require("../../../mappers/responseMapper");
|
|
4
3
|
const join_1 = require("../join");
|
|
5
4
|
const joinWith_1 = require("../joinWith");
|
|
6
5
|
const selectResponseFourJoins_1 = require("../responses/selectResponseFourJoins");
|
|
7
6
|
const abstractJoinBuilder_1 = require("./abstractJoinBuilder");
|
|
8
7
|
const selectWithFiveJoins_1 = require("./selectWithFiveJoins");
|
|
9
8
|
class SelectTRBWithFourJoins extends abstractJoinBuilder_1.default {
|
|
10
|
-
constructor(table, session, filter, join1, join2, join3, join4, props, orderBy, order, distinct) {
|
|
11
|
-
super(table, filter, session, props, orderBy, order, distinct);
|
|
9
|
+
constructor(table, session, filter, join1, join2, join3, join4, props, orderBy, order, distinct, tablePartial, joinedPartial, joinedPartial1, joinedPartial2, joinedPartial3) {
|
|
10
|
+
super(table, filter, session, props, orderBy, order, distinct, tablePartial);
|
|
12
11
|
this._join1 = join1;
|
|
13
12
|
this._join2 = join2;
|
|
14
13
|
this._join3 = join3;
|
|
15
14
|
this._join4 = join4;
|
|
15
|
+
this._joinedPartial = joinedPartial;
|
|
16
|
+
this._joinedPartial1 = joinedPartial1;
|
|
17
|
+
this._joinedPartial2 = joinedPartial2;
|
|
18
|
+
this._joinedPartial3 = joinedPartial3;
|
|
16
19
|
}
|
|
17
|
-
innerJoin(table, from, to) {
|
|
20
|
+
innerJoin(fromTable, table, from, to, partial) {
|
|
18
21
|
const toTable = this._table.db.create(table);
|
|
19
|
-
const
|
|
22
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
23
|
+
const fromColumn = from(tableFrom);
|
|
20
24
|
const toColumn = to(toTable);
|
|
21
25
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
22
26
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.INNER_JOIN);
|
|
23
|
-
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct);
|
|
27
|
+
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, this._joinedPartial3, partial);
|
|
24
28
|
}
|
|
25
|
-
leftJoin(table, from, to) {
|
|
29
|
+
leftJoin(fromTable, table, from, to, partial) {
|
|
26
30
|
const toTable = this._table.db.create(table);
|
|
27
|
-
const
|
|
31
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
32
|
+
const fromColumn = from(tableFrom);
|
|
28
33
|
const toColumn = to(toTable);
|
|
29
34
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
30
35
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.LEFT_JOIN);
|
|
31
|
-
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct);
|
|
36
|
+
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, this._joinedPartial3, partial);
|
|
32
37
|
}
|
|
33
|
-
rightJoin(table, from, to) {
|
|
38
|
+
rightJoin(fromTable, table, from, to, partial) {
|
|
34
39
|
const toTable = this._table.db.create(table);
|
|
35
|
-
const
|
|
40
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
41
|
+
const fromColumn = from(tableFrom);
|
|
36
42
|
const toColumn = to(toTable);
|
|
37
43
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
38
44
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.RIGHT_JOIN);
|
|
39
|
-
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct);
|
|
45
|
+
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, this._joinedPartial3, partial);
|
|
40
46
|
}
|
|
41
|
-
fullJoin(table, from, to) {
|
|
47
|
+
fullJoin(fromTable, table, from, to, partial) {
|
|
42
48
|
const toTable = this._table.db.create(table);
|
|
43
|
-
const
|
|
49
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
50
|
+
const fromColumn = from(tableFrom);
|
|
44
51
|
const toColumn = to(toTable);
|
|
45
52
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
46
53
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.FULL_JOIN);
|
|
47
|
-
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct);
|
|
54
|
+
return new selectWithFiveJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, this._join4, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, this._joinedPartial3, partial);
|
|
48
55
|
}
|
|
49
56
|
joins() {
|
|
50
|
-
return [this._join1, this.
|
|
57
|
+
return [{ join: this._join1, partial: this._joinedPartial, id: 1 },
|
|
58
|
+
{ join: this._join2, partial: this._joinedPartial1, id: 2 },
|
|
59
|
+
{ join: this._join3, partial: this._joinedPartial2, id: 3 },
|
|
60
|
+
{ join: this._join4, partial: this._joinedPartial3, id: 4 }];
|
|
51
61
|
}
|
|
52
62
|
mapResponse(result) {
|
|
53
63
|
const parent = this._join1.mappedServiceToDb;
|
|
54
64
|
const parentTwo = this._join2.mappedServiceToDb;
|
|
55
65
|
const parentThree = this._join3.mappedServiceToDb;
|
|
56
66
|
const parentFour = this._join4.mappedServiceToDb;
|
|
57
|
-
const response =
|
|
58
|
-
const objects =
|
|
59
|
-
const objectsTwo =
|
|
60
|
-
const objectsThree =
|
|
61
|
-
const objectsFour =
|
|
67
|
+
const response = this.fullOrPartial(this._table.mapServiceToDb(), result, this._partial);
|
|
68
|
+
const objects = this.fullOrPartial(parent, result, this._joinedPartial, 1);
|
|
69
|
+
const objectsTwo = this.fullOrPartial(parentTwo, result, this._joinedPartial1, 2);
|
|
70
|
+
const objectsThree = this.fullOrPartial(parentThree, result, this._joinedPartial2, 3);
|
|
71
|
+
const objectsFour = this.fullOrPartial(parentFour, result, this._joinedPartial3, 4);
|
|
62
72
|
return new selectResponseFourJoins_1.default(response, objects, objectsTwo, objectsThree, objectsFour);
|
|
63
73
|
}
|
|
64
74
|
}
|
|
@@ -4,30 +4,46 @@ import ColumnType from '../../../columns/types/columnType';
|
|
|
4
4
|
import DB from '../../../db/db';
|
|
5
5
|
import { ISession } from '../../../db/session';
|
|
6
6
|
import AbstractTable from '../../../tables/abstractTable';
|
|
7
|
+
import { CheckTwoTypes, PartialFor } from '../../../tables/inferTypes';
|
|
7
8
|
import Order from '../../highLvlBuilders/order';
|
|
8
9
|
import Expr from '../../requestBuilders/where/where';
|
|
9
10
|
import Join from '../join';
|
|
10
11
|
import SelectResponseJoin from '../responses/selectResponseWithJoin';
|
|
11
12
|
import AbstractJoined from './abstractJoinBuilder';
|
|
12
13
|
import SelectTRBWithTwoJoins from './selectWithTwoJoins';
|
|
13
|
-
export default class SelectTRBWithJoin<TTable extends AbstractTable<TTable>, TTable1> extends AbstractJoined<TTable, SelectResponseJoin<TTable, TTable1
|
|
14
|
+
export default class SelectTRBWithJoin<TTable extends AbstractTable<TTable>, TTable1 extends AbstractTable<TTable1>, TPartial extends PartialFor<TTable> = {}, TPartial1 extends PartialFor<TTable1> = {}> extends AbstractJoined<TTable, SelectResponseJoin<TTable, TTable1, TPartial, TPartial1>, TPartial> {
|
|
14
15
|
private _join;
|
|
16
|
+
private _joinedPartial?;
|
|
15
17
|
constructor(table: TTable, session: ISession, filter: Expr, join: Join<TTable1>, props: {
|
|
16
18
|
limit?: number;
|
|
17
19
|
offset?: number;
|
|
18
|
-
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean
|
|
19
|
-
innerJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
20
|
+
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean>, tablePartial?: TPartial, joinedPartial?: TPartial1);
|
|
21
|
+
innerJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
22
|
+
new (db: DB): InputTable;
|
|
23
|
+
}, table: {
|
|
20
24
|
new (db: DB): IToTable;
|
|
21
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
22
|
-
leftJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
25
|
+
}, from: (table: CheckTwoTypes<InputTable, TTable, TTable1>) => AbstractColumn<TColumn, boolean, boolean, CheckTwoTypes<InputTable, TTable, TTable1>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithTwoJoins<TTable, TTable1, IToTable, TPartial, TPartial1, IToPartial>;
|
|
26
|
+
leftJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
27
|
+
new (db: DB): InputTable;
|
|
28
|
+
}, table: {
|
|
23
29
|
new (db: DB): IToTable;
|
|
24
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
25
|
-
rightJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
30
|
+
}, from: (table: CheckTwoTypes<InputTable, TTable, TTable1>) => AbstractColumn<TColumn, boolean, boolean, CheckTwoTypes<InputTable, TTable, TTable1>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithTwoJoins<TTable, TTable1, IToTable, TPartial, TPartial1, IToPartial>;
|
|
31
|
+
rightJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
32
|
+
new (db: DB): InputTable;
|
|
33
|
+
}, table: {
|
|
26
34
|
new (db: DB): IToTable;
|
|
27
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
28
|
-
fullJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
35
|
+
}, from: (table: CheckTwoTypes<InputTable, TTable, TTable1>) => AbstractColumn<TColumn, boolean, boolean, CheckTwoTypes<InputTable, TTable, TTable1>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithTwoJoins<TTable, TTable1, IToTable, TPartial, TPartial1, IToPartial>;
|
|
36
|
+
fullJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
37
|
+
new (db: DB): InputTable;
|
|
38
|
+
}, table: {
|
|
29
39
|
new (db: DB): IToTable;
|
|
30
|
-
}, from: (table: TTable) => AbstractColumn<TColumn
|
|
31
|
-
protected joins():
|
|
32
|
-
|
|
40
|
+
}, from: (table: CheckTwoTypes<InputTable, TTable, TTable1>) => AbstractColumn<TColumn, boolean, boolean, CheckTwoTypes<InputTable, TTable, TTable1>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithTwoJoins<TTable, TTable1, IToTable, TPartial, TPartial1, IToPartial>;
|
|
41
|
+
protected joins(): Array<{
|
|
42
|
+
join: Join<any>;
|
|
43
|
+
partial?: {
|
|
44
|
+
[name: string]: AbstractColumn<ColumnType<any>, boolean, boolean, any>;
|
|
45
|
+
};
|
|
46
|
+
id?: number;
|
|
47
|
+
}>;
|
|
48
|
+
protected mapResponse(result: QueryResult<any>): SelectResponseJoin<TTable, TTable1, TPartial, TPartial1>;
|
|
33
49
|
}
|
|
@@ -1,55 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const responseMapper_1 = require("../../../mappers/responseMapper");
|
|
4
3
|
const join_1 = require("../join");
|
|
5
4
|
const joinWith_1 = require("../joinWith");
|
|
6
5
|
const selectResponseWithJoin_1 = require("../responses/selectResponseWithJoin");
|
|
7
6
|
const abstractJoinBuilder_1 = require("./abstractJoinBuilder");
|
|
8
7
|
const selectWithTwoJoins_1 = require("./selectWithTwoJoins");
|
|
8
|
+
// eslint-disable-next-line max-len
|
|
9
9
|
class SelectTRBWithJoin extends abstractJoinBuilder_1.default {
|
|
10
|
-
constructor(table, session, filter, join, props, orderBy, order, distinct) {
|
|
11
|
-
super(table, filter, session, props, orderBy, order, distinct);
|
|
10
|
+
constructor(table, session, filter, join, props, orderBy, order, distinct, tablePartial, joinedPartial) {
|
|
11
|
+
super(table, filter, session, props, orderBy, order, distinct, tablePartial);
|
|
12
12
|
this._join = join;
|
|
13
|
+
this._joinedPartial = joinedPartial;
|
|
13
14
|
}
|
|
14
|
-
innerJoin(table, from, to) {
|
|
15
|
+
innerJoin(fromTable, table, from, to, partial) {
|
|
15
16
|
const toTable = this._table.db.create(table);
|
|
16
|
-
const
|
|
17
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
18
|
+
const fromColumn = from(tableFrom);
|
|
17
19
|
const toColumn = to(toTable);
|
|
18
20
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
19
21
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.INNER_JOIN);
|
|
20
|
-
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct);
|
|
22
|
+
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, partial);
|
|
21
23
|
}
|
|
22
|
-
leftJoin(table, from, to) {
|
|
24
|
+
leftJoin(fromTable, table, from, to, partial) {
|
|
23
25
|
const toTable = this._table.db.create(table);
|
|
24
|
-
const
|
|
26
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
27
|
+
const fromColumn = from(tableFrom);
|
|
25
28
|
const toColumn = to(toTable);
|
|
26
29
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
27
30
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.LEFT_JOIN);
|
|
28
|
-
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct);
|
|
31
|
+
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, partial);
|
|
29
32
|
}
|
|
30
|
-
rightJoin(table, from, to) {
|
|
33
|
+
rightJoin(fromTable, table, from, to, partial) {
|
|
31
34
|
const toTable = this._table.db.create(table);
|
|
32
|
-
const
|
|
35
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
36
|
+
const fromColumn = from(tableFrom);
|
|
33
37
|
const toColumn = to(toTable);
|
|
34
38
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
35
39
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.RIGHT_JOIN);
|
|
36
|
-
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct);
|
|
40
|
+
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, partial);
|
|
37
41
|
}
|
|
38
|
-
fullJoin(table, from, to) {
|
|
42
|
+
fullJoin(fromTable, table, from, to, partial) {
|
|
39
43
|
const toTable = this._table.db.create(table);
|
|
40
|
-
const
|
|
44
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
45
|
+
const fromColumn = from(tableFrom);
|
|
41
46
|
const toColumn = to(toTable);
|
|
42
47
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
43
48
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.FULL_JOIN);
|
|
44
|
-
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct);
|
|
49
|
+
return new selectWithTwoJoins_1.default(this._table, this._session, this._filter, this._join, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, partial);
|
|
45
50
|
}
|
|
46
51
|
joins() {
|
|
47
|
-
return [this._join];
|
|
52
|
+
return [{ join: this._join, partial: this._joinedPartial, id: 1 }];
|
|
48
53
|
}
|
|
49
54
|
mapResponse(result) {
|
|
50
55
|
const parent = this._join.mappedServiceToDb;
|
|
51
|
-
const response =
|
|
52
|
-
const objects =
|
|
56
|
+
const response = this.fullOrPartial(this._table.mapServiceToDb(), result, this._partial);
|
|
57
|
+
const objects = this.fullOrPartial(parent, result, this._joinedPartial, 1);
|
|
53
58
|
return new selectResponseWithJoin_1.default(response, objects);
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -4,32 +4,50 @@ import ColumnType from '../../../columns/types/columnType';
|
|
|
4
4
|
import DB from '../../../db/db';
|
|
5
5
|
import { ISession } from '../../../db/session';
|
|
6
6
|
import AbstractTable from '../../../tables/abstractTable';
|
|
7
|
+
import { CheckFourTypes, PartialFor } from '../../../tables/inferTypes';
|
|
7
8
|
import Order from '../../highLvlBuilders/order';
|
|
8
9
|
import Expr from '../../requestBuilders/where/where';
|
|
9
10
|
import Join from '../join';
|
|
10
11
|
import SelectResponseThreeJoins from '../responses/selectResponseThreeJoins';
|
|
11
12
|
import AbstractJoined from './abstractJoinBuilder';
|
|
12
13
|
import SelectTRBWithFourJoins from './selectWithFourJoins';
|
|
13
|
-
export default class SelectTRBWithThreeJoins<TTable extends AbstractTable<TTable>, TTable1, TTable2, TTable3> extends AbstractJoined<TTable, SelectResponseThreeJoins<TTable, TTable1, TTable2, TTable3
|
|
14
|
+
export default class SelectTRBWithThreeJoins<TTable extends AbstractTable<TTable>, TTable1 extends AbstractTable<TTable1>, TTable2 extends AbstractTable<TTable2>, TTable3 extends AbstractTable<TTable3>, TPartial extends PartialFor<TTable> = {}, TPartial1 extends PartialFor<TTable1> = {}, TPartial2 extends PartialFor<TTable2> = {}, TPartial3 extends PartialFor<TTable3> = {}> extends AbstractJoined<TTable, SelectResponseThreeJoins<TTable, TTable1, TTable2, TTable3, TPartial, TPartial1, TPartial2, TPartial3>, TPartial> {
|
|
14
15
|
private _join1;
|
|
15
16
|
private _join2;
|
|
16
17
|
private _join3;
|
|
18
|
+
private _joinedPartial?;
|
|
19
|
+
private _joinedPartial1?;
|
|
20
|
+
private _joinedPartial2?;
|
|
17
21
|
constructor(table: TTable, session: ISession, filter: Expr, join1: Join<TTable1>, join2: Join<TTable2>, join3: Join<TTable3>, props: {
|
|
18
22
|
limit?: number;
|
|
19
23
|
offset?: number;
|
|
20
|
-
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean
|
|
21
|
-
innerJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
24
|
+
}, orderBy?: AbstractColumn<ColumnType, boolean, boolean>, order?: Order, distinct?: AbstractColumn<ColumnType, boolean, boolean>, tablePartial?: TPartial, joinedPartial?: TPartial1, joinedPartial1?: TPartial2, joinedPartial2?: TPartial3);
|
|
25
|
+
innerJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
26
|
+
new (db: DB): InputTable;
|
|
27
|
+
}, table: {
|
|
22
28
|
new (db: DB): IToTable;
|
|
23
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
24
|
-
leftJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
29
|
+
}, from: (table: CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>) => AbstractColumn<TColumn, boolean, boolean, CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithFourJoins<TTable, TTable1, TTable2, TTable3, IToTable, TPartial, TPartial1, TPartial2, TPartial3, IToPartial>;
|
|
30
|
+
leftJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
31
|
+
new (db: DB): InputTable;
|
|
32
|
+
}, table: {
|
|
25
33
|
new (db: DB): IToTable;
|
|
26
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
27
|
-
rightJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
34
|
+
}, from: (table: CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>) => AbstractColumn<TColumn, boolean, boolean, CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithFourJoins<TTable, TTable1, TTable2, TTable3, IToTable, TPartial, TPartial1, TPartial2, TPartial3, IToPartial>;
|
|
35
|
+
rightJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
36
|
+
new (db: DB): InputTable;
|
|
37
|
+
}, table: {
|
|
28
38
|
new (db: DB): IToTable;
|
|
29
|
-
}, from: (table: TTable) => AbstractColumn<TColumn, boolean, boolean
|
|
30
|
-
fullJoin<TColumn extends ColumnType, IToTable extends AbstractTable<IToTable
|
|
39
|
+
}, from: (table: CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>) => AbstractColumn<TColumn, boolean, boolean, CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithFourJoins<TTable, TTable1, TTable2, TTable3, IToTable, TPartial, TPartial1, TPartial2, TPartial3, IToPartial>;
|
|
40
|
+
fullJoin<InputTable extends AbstractTable<InputTable>, TColumn extends ColumnType, IToTable extends AbstractTable<IToTable>, IToPartial extends PartialFor<IToTable> = {}>(fromTable: {
|
|
41
|
+
new (db: DB): InputTable;
|
|
42
|
+
}, table: {
|
|
31
43
|
new (db: DB): IToTable;
|
|
32
|
-
}, from: (table: TTable) => AbstractColumn<TColumn
|
|
33
|
-
protected mapResponse(result: QueryResult<any>): SelectResponseThreeJoins<TTable, TTable1, TTable2, TTable3>;
|
|
34
|
-
protected joins():
|
|
44
|
+
}, from: (table: CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>) => AbstractColumn<TColumn, boolean, boolean, CheckFourTypes<InputTable, TTable, TTable1, TTable2, TTable3>>, to: (table: IToTable) => AbstractColumn<TColumn, boolean, boolean, IToTable>, partial?: IToPartial): SelectTRBWithFourJoins<TTable, TTable1, TTable2, TTable3, IToTable, TPartial, TPartial1, TPartial2, TPartial3, IToPartial>;
|
|
45
|
+
protected mapResponse(result: QueryResult<any>): SelectResponseThreeJoins<TTable, TTable1, TTable2, TTable3, TPartial, TPartial1, TPartial2, TPartial3>;
|
|
46
|
+
protected joins(): Array<{
|
|
47
|
+
join: Join<any>;
|
|
48
|
+
partial?: {
|
|
49
|
+
[name: string]: AbstractColumn<ColumnType<any>, boolean, boolean, any>;
|
|
50
|
+
};
|
|
51
|
+
id?: number;
|
|
52
|
+
}>;
|
|
35
53
|
}
|
|
@@ -1,62 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const responseMapper_1 = require("../../../mappers/responseMapper");
|
|
4
3
|
const join_1 = require("../join");
|
|
5
4
|
const joinWith_1 = require("../joinWith");
|
|
6
5
|
const selectResponseThreeJoins_1 = require("../responses/selectResponseThreeJoins");
|
|
7
6
|
const abstractJoinBuilder_1 = require("./abstractJoinBuilder");
|
|
8
7
|
const selectWithFourJoins_1 = require("./selectWithFourJoins");
|
|
9
8
|
class SelectTRBWithThreeJoins extends abstractJoinBuilder_1.default {
|
|
10
|
-
constructor(table, session, filter, join1, join2, join3, props, orderBy, order, distinct) {
|
|
11
|
-
super(table, filter, session, props, orderBy, order, distinct);
|
|
9
|
+
constructor(table, session, filter, join1, join2, join3, props, orderBy, order, distinct, tablePartial, joinedPartial, joinedPartial1, joinedPartial2) {
|
|
10
|
+
super(table, filter, session, props, orderBy, order, distinct, tablePartial);
|
|
12
11
|
this._join1 = join1;
|
|
13
12
|
this._join2 = join2;
|
|
14
13
|
this._join3 = join3;
|
|
14
|
+
this._joinedPartial = joinedPartial;
|
|
15
|
+
this._joinedPartial1 = joinedPartial1;
|
|
16
|
+
this._joinedPartial2 = joinedPartial2;
|
|
15
17
|
}
|
|
16
|
-
innerJoin(table, from, to) {
|
|
18
|
+
innerJoin(fromTable, table, from, to, partial) {
|
|
17
19
|
const toTable = this._table.db.create(table);
|
|
18
|
-
const
|
|
20
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
21
|
+
const fromColumn = from(tableFrom);
|
|
19
22
|
const toColumn = to(toTable);
|
|
20
23
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
21
24
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.INNER_JOIN);
|
|
22
|
-
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct);
|
|
25
|
+
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, partial);
|
|
23
26
|
}
|
|
24
|
-
leftJoin(table, from, to) {
|
|
27
|
+
leftJoin(fromTable, table, from, to, partial) {
|
|
25
28
|
const toTable = this._table.db.create(table);
|
|
26
|
-
const
|
|
29
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
30
|
+
const fromColumn = from(tableFrom);
|
|
27
31
|
const toColumn = to(toTable);
|
|
28
32
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
29
33
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.LEFT_JOIN);
|
|
30
|
-
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct);
|
|
34
|
+
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, partial);
|
|
31
35
|
}
|
|
32
|
-
rightJoin(table, from, to) {
|
|
36
|
+
rightJoin(fromTable, table, from, to, partial) {
|
|
33
37
|
const toTable = this._table.db.create(table);
|
|
34
|
-
const
|
|
38
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
39
|
+
const fromColumn = from(tableFrom);
|
|
35
40
|
const toColumn = to(toTable);
|
|
36
41
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
37
42
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.RIGHT_JOIN);
|
|
38
|
-
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct);
|
|
43
|
+
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, partial);
|
|
39
44
|
}
|
|
40
|
-
fullJoin(table, from, to) {
|
|
45
|
+
fullJoin(fromTable, table, from, to, partial) {
|
|
41
46
|
const toTable = this._table.db.create(table);
|
|
42
|
-
const
|
|
47
|
+
const tableFrom = this._table.db.create(fromTable);
|
|
48
|
+
const fromColumn = from(tableFrom);
|
|
43
49
|
const toColumn = to(toTable);
|
|
44
50
|
const join = new joinWith_1.default(toTable.tableName(), toTable.mapServiceToDb())
|
|
45
51
|
.columns(fromColumn, toColumn).joinStrategy(join_1.JoinStrategy.FULL_JOIN);
|
|
46
|
-
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct);
|
|
52
|
+
return new selectWithFourJoins_1.default(this._table, this._session, this._filter, this._join1, this._join2, this._join3, join, this._props, this._orderBy, this._order, this._distinct, this._partial, this._joinedPartial, this._joinedPartial1, this._joinedPartial2, partial);
|
|
47
53
|
}
|
|
48
54
|
mapResponse(result) {
|
|
49
55
|
const parent = this._join1.mappedServiceToDb;
|
|
50
56
|
const parentTwo = this._join2.mappedServiceToDb;
|
|
51
57
|
const parentThree = this._join3.mappedServiceToDb;
|
|
52
|
-
const response =
|
|
53
|
-
const objects =
|
|
54
|
-
const objectsTwo =
|
|
55
|
-
const objectsThree =
|
|
58
|
+
const response = this.fullOrPartial(this._table.mapServiceToDb(), result, this._partial);
|
|
59
|
+
const objects = this.fullOrPartial(parent, result, this._joinedPartial, 1);
|
|
60
|
+
const objectsTwo = this.fullOrPartial(parentTwo, result, this._joinedPartial1, 2);
|
|
61
|
+
const objectsThree = this.fullOrPartial(parentThree, result, this._joinedPartial2, 3);
|
|
56
62
|
return new selectResponseThreeJoins_1.default(response, objects, objectsTwo, objectsThree);
|
|
57
63
|
}
|
|
58
64
|
joins() {
|
|
59
|
-
return [this._join1, this.
|
|
65
|
+
return [{ join: this._join1, partial: this._joinedPartial, id: 1 },
|
|
66
|
+
{ join: this._join2, partial: this._joinedPartial1, id: 2 },
|
|
67
|
+
{ join: this._join3, partial: this._joinedPartial2, id: 3 }];
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
exports.default = SelectTRBWithThreeJoins;
|