@@ -4,6 +4,7 @@ import { ColumnsCompiled } from "../core/columns-compiled";
44import { QueryCompiled } from "../core/query-compiled" ;
55import { CrudCompiled } from "../core/crud-compiled" ;
66import { WhereCompiled } from "./where-compiled" ;
7+ import { MetadataTable } from "../metadata-table" ;
78
89let NEXT_VALUE_ALIAS : number = 0 ;
910
@@ -16,6 +17,7 @@ export abstract class CrudBaseBuilder<T, TColumnsBuilder extends ColumnsValuesBu
1617
1718 constructor (
1819 protected readonly _typeT : new ( ) => T ,
20+ protected metadata : MetadataTable < T > ,
1921 protected readonly _alias : string = void 0 ,
2022 ) {
2123 this . _tablename = _typeT . name ;
@@ -24,6 +26,10 @@ export abstract class CrudBaseBuilder<T, TColumnsBuilder extends ColumnsValuesBu
2426 }
2527 }
2628
29+ public getMetadata ( ) : MetadataTable < T > {
30+ return this . metadata ;
31+ }
32+
2733 public hasAlias ( alias : string ) : boolean {
2834 if ( this . _alias === alias ) {
2935 return true ;
@@ -39,6 +45,30 @@ export abstract class CrudBaseBuilder<T, TColumnsBuilder extends ColumnsValuesBu
3945 } ;
4046 }
4147
48+ // public setKeyByModel(keyValue: any): void {
49+ // (this.getModel() as any)[this.primaryKeyMapper().fieldReference] = keyValue;
50+ // }
51+
52+ // public getKeyByModel(): any {
53+ // return Utils.getValue(this.getModel(), this.primaryKeyMapper().fieldReference);
54+ // }
55+
56+ // public primaryKeyType(): PrimaryKeyType {
57+ // return this.primaryKeyMapper().primaryKeyType;
58+ // }
59+
60+ // public isCompositeKey(): boolean {
61+ // return this.primaryKeysMapper().length > 1;
62+ // }
63+
64+ // public primaryKeyMapper(): MapperColumn {
65+ // return this.primaryKeysMapper().find(_ => true);
66+ // }
67+
68+ // public primaryKeysMapper(): MapperColumn[] {
69+ // return this.metadata.mapperTable.columns.filter(x => !!x.primaryKeyType);
70+ // }
71+
4272 protected getColumnsCompiled ( ) : ColumnsCompiled {
4373 if ( ! this . _columnsCompiled . columns . length ) {
4474 this . setDefaultColumns ( ) ;
@@ -70,6 +100,8 @@ export abstract class CrudBaseBuilder<T, TColumnsBuilder extends ColumnsValuesBu
70100
71101 protected abstract setDefaultColumns ( ) : void ;
72102
103+ public abstract getModel ( ) : T ;
104+
73105 private compileWhere ( compiled : WhereCompiled ) {
74106 if ( compiled . where . length ) {
75107 this . _whereCompiled . where += `${ ( this . _whereCompiled . where . length ? " AND " : " WHERE " ) } ${ compiled . where } ` ;
0 commit comments