import * as sd from "type-mapping"; import {Key} from "../key"; import {AliasedTableData, IAliasedTable} from "../aliased-table"; import {AssertMap} from "../assert-map"; import {QueryTree} from "../query-tree"; import {PrimaryKey, PrimaryKeyUtil} from "../primary-key"; import {CandidateKey, CandidateKeyUtil} from "../candidate-key"; import {SuperKey, SuperKeyUtil} from "../super-key"; import { IConnection, UpdateOneResult, UpdateZeroOrOneResult, DeleteOneResult, DeleteZeroOrOneResult, } from "../execution"; import {QueryUtil} from "../query"; import {Row} from "../row"; import {RawExprUtil} from "../raw-expr"; import {InsertRow, InsertUtil} from "../insert"; import {UpdateUtil} from "../update"; import {DeleteUtil} from "../delete"; import * as TableUtil from "./util"; export interface TableData extends AliasedTableData { //The maximum value `UNSIGNED BIGINT` can have is //18446744073709551615 //which is 2^(32*8)-1 because `UNSIGNED BIGINT` uses 8 bytes. //`UNSIGNED BIGINT` can have up to 20 digits... //This cannot be represented correctly with JS' `number` type, //which should be an 8-byte floating point, //The maximum safe value is Number.MAX_SAFE_INTEGER //which is 9,007,199,254,740,991 readonly autoIncrement : undefined|string; //A table can have a PK that is an FK to an auto-increment column in another table readonly id : undefined|string; /* A primary key is just a candidate key. With the additional restriction that all its columns cannot be nullable! Apart from that, the only thing "special" about it is that we say, "This is *the* candidate key I want to talk about by default" */ readonly primaryKey : undefined|Key; readonly candidateKeys : Key[]; //If a column is generated, you must specify as such manually. //Setting generated column values will not be allowed with INSERT statements. //Updating generated column values will also not be allowed with UPDATE statements. readonly generated : string[]; //If a column is nullable, it has a server default value of `NULL`. //A nullable column has a default value *implicitly*. /* const t1 = table( "tableName", { column : sd.orNull(o.bigint()) } ); t1.isNullable is now ["column"] because "column" is is nullable. const t2 = t1.addColumns({ column : o.bigint() }); t2.isNullable is now [] because "column" is no longer nullable. */ readonly isNullable : string[]; //If a column is NOT nullable, but has a server default value, //like CURRENT_TIMESTAMP or some other value, //you will have to specify as such manually. //If a column is a GENERATED column, then it also has a server default value. //Columns with server default values are optional with INSERT statements. readonly hasExplicitDefaultValue : string[]; //By default, all non-generated columns of the table are mutable. //Calling setMutable() will set only the specified columns as mutable. //Calling setImmutable() will make them all immutable. //Generated columns cannot be mutable. readonly mutable : string[]; /* A parent table must be instantiated before the child table. The parent and child table must share at least one unique key (usually the `id`) If there are duplicate column names, it is assumed there is an FK of that column from the child table to the parent table, and that the child's column type is assignable to the parent's column type. An example would be "discriminator" columns used in exclusive inheritance. The parent table could have a column, `appKeyType`, which would be `BROWSER|SERVER`. The child table would, then, have a column called `appKeyType` with `SERVER` as the only value. We outline some possibilities for duplicate columns, Child | Parent | generated | generated | When inserting, the column value is ignored generated | has default | The child column's generated value must be a numeric string generated | no default | The child column's generated value must be a numeric string has default | generated | The parent column must a unique key we can use to retrieve after insertion, to get the value has default | has default | If value is provided, it'll set both to the value, otherwise, it lets the defaults be set has default | no default | The value must be provided, it'll set both to the value no default | generated | The parent column must a unique key we can use to retrieve after insertion, to get the value no default | has default | The parent column must a unique key we can use to retrieve after insertion, to get the value no default | no default | The value must be provided, it'll set both to the value */ readonly parents : ITable[]; //Defaults to `true` readonly insertAllowed : boolean; //Defaults to `true` readonly deleteAllowed : boolean; } export interface ITable extends IAliasedTable { readonly usedRef : DataT["usedRef"]; readonly alias : DataT["alias"]; readonly columns : DataT["columns"]; readonly unaliasedQuery : QueryTree; readonly autoIncrement : DataT["autoIncrement"]; readonly id : DataT["id"]; readonly primaryKey : DataT["primaryKey"]; readonly candidateKeys : DataT["candidateKeys"]; readonly generated : DataT["generated"]; readonly isNullable : DataT["isNullable"]; readonly hasExplicitDefaultValue : DataT["hasExplicitDefaultValue"]; readonly mutable : DataT["mutable"]; readonly parents : DataT["parents"]; readonly insertAllowed : DataT["insertAllowed"]; readonly deleteAllowed : DataT["deleteAllowed"]; } export type InsertableTable = ( ITable & { insertAllowed : true } ); export type DeletableTable = ( ITable & { deleteAllowed : true } ); export type TableWithPk = ( ITable & { primaryKey : Key } ); export class Table implements ITable { readonly usedRef : DataT["usedRef"]; readonly alias : DataT["alias"]; readonly columns : DataT["columns"]; readonly unaliasedQuery : QueryTree; readonly autoIncrement : DataT["autoIncrement"]; readonly id : DataT["id"]; readonly primaryKey : DataT["primaryKey"]; readonly candidateKeys : DataT["candidateKeys"]; readonly generated : DataT["generated"]; readonly isNullable : DataT["isNullable"]; readonly hasExplicitDefaultValue : DataT["hasExplicitDefaultValue"]; readonly mutable : DataT["mutable"]; readonly parents : DataT["parents"]; readonly insertAllowed : DataT["insertAllowed"]; readonly deleteAllowed : DataT["deleteAllowed"]; constructor ( data : DataT, { unaliasedQuery, } : { unaliasedQuery : QueryTree, } ) { this.usedRef = data.usedRef; this.alias = data.alias; this.columns = data.columns; this.unaliasedQuery = unaliasedQuery; this.autoIncrement = data.autoIncrement; this.id = data.id; this.primaryKey = data.primaryKey; this.candidateKeys = data.candidateKeys; this.generated = data.generated; this.isNullable = data.isNullable; this.hasExplicitDefaultValue = data.hasExplicitDefaultValue; this.mutable = data.mutable; this.parents = data.parents; this.insertAllowed = data.insertAllowed; this.deleteAllowed = data.deleteAllowed; } as (newAlias : NewAliasT) : TableUtil.As { return TableUtil.as(this, newAlias); } //A cache to re-use the assert delegate private cachedCandidateKeyAssertDelegate : ( undefined | CandidateKeyUtil.AssertDelegate ); candidateKeyAssertDelegate () : CandidateKeyUtil.AssertDelegate { if (this.cachedCandidateKeyAssertDelegate == undefined) { this.cachedCandidateKeyAssertDelegate = ( CandidateKeyUtil.assertDelegate(this) ); } return this.cachedCandidateKeyAssertDelegate; } //A cache to re-use the assert delegate private cachedSuperKeyAssertDelegate : ( undefined | SuperKeyUtil.AssertDelegate ); superKeyAssertDelegate () : SuperKeyUtil.AssertDelegate { if (this.cachedSuperKeyAssertDelegate == undefined) { this.cachedSuperKeyAssertDelegate = ( SuperKeyUtil.assertDelegate(this) ); } return this.cachedSuperKeyAssertDelegate; } //A cache to re-use the assert delegate private cachedPrimaryKeyAssertDelegate : ( undefined | PrimaryKeyUtil.AssertDelegate< Extract > ); primaryKeyAssertDelegate ( this : Extract ) : ( PrimaryKeyUtil.AssertDelegate< Extract > ) { if (this.cachedPrimaryKeyAssertDelegate == undefined) { this.cachedPrimaryKeyAssertDelegate = ( PrimaryKeyUtil.assertDelegate(this) ) as any; } //TODO Figure out why it isn't working return this.cachedPrimaryKeyAssertDelegate as any; } setAlias( newAlias : NewAliasT ) : TableUtil.SetAlias { return TableUtil.setAlias(this, newAlias); } addColumns< FieldsT extends sd.AnyField[] > ( fields : FieldsT ) : ( TableUtil.AddColumnsFromFieldTuple ); addColumns< AssertMapT extends AssertMap > ( assertMap : AssertMapT ) : ( TableUtil.AddColumnsFromAssertMap ); addColumns (rawColumns : any) : any { return TableUtil.addColumns(this, rawColumns); } setAutoIncrement< DelegateT extends TableUtil.AutoIncrementDelegate > ( delegate : DelegateT ) : TableUtil.SetAutoIncrement { return TableUtil.setAutoIncrement< this, DelegateT >(this, delegate); } setDatabaseName ( newDatabaseName : string ) : ( TableUtil.SetDatabaseName ) { return TableUtil.setDatabaseName(this, newDatabaseName); } setId< DelegateT extends TableUtil.IdDelegate > ( delegate : DelegateT ) : ( TableUtil.SetId ) { return TableUtil.setId< this, DelegateT >(this, delegate); } setPrimaryKey< DelegateT extends TableUtil.PrimaryKeyDelegate > ( delegate : TableUtil.AssertValidCandidateKeyDelegate ) : ( TableUtil.AssertValidCandidateKeyDelegate_Hack< this, DelegateT, TableUtil.SetPrimaryKey > //TableUtil.SetPrimaryKey ) { return TableUtil.setPrimaryKey< this, DelegateT >(this, delegate); } /* Adding a candidate key that is a super-set of an existing candidate key should throw an error, both during compile-time and run-time. Candidate keys should be as small as possible. */ addCandidateKey< DelegateT extends TableUtil.CandidateKeyDelegate > ( delegate : TableUtil.AssertValidCandidateKeyDelegate ) : ( TableUtil.AssertValidCandidateKeyDelegate_Hack< this, DelegateT, TableUtil.AddCandidateKey > //TableUtil.AddCandidateKey ) { return TableUtil.addCandidateKey(this, delegate); } addGenerated< DelegateT extends TableUtil.GeneratedDelegate > ( delegate : DelegateT ) : ( TableUtil.AddGenerated ) { return TableUtil.addGenerated(this, delegate); } addHasExplicitDefaultValue< DelegateT extends TableUtil.HasExplicitDefaultValueDelegate > ( delegate : DelegateT ) : ( TableUtil.AddHasExplicitDefaultValue ) { return TableUtil.addHasExplicitDefaultValue(this, delegate); } setImmutable () : TableUtil.SetImmutable { return TableUtil.setImmutable(this); } setMutable< DelegateT extends TableUtil.MutableDelegate > ( delegate : DelegateT ) : ( TableUtil.SetMutable ) { return TableUtil.setMutable(this, delegate); } addParent< ParentT extends ITable > ( parent : TableUtil.Parent ) : ( TableUtil.AddParent ) { return TableUtil.addParent(this, parent); } disallowInsert () : TableUtil.DisallowInsert { return TableUtil.disallowInsert(this); } disallowDelete () : TableUtil.DisallowDelete { return TableUtil.disallowDelete(this); } validate (connection : IConnection, result : TableUtil.ValidateTableResult) { return TableUtil.validate(this, connection, result); } assertExistsByCk ( connection : IConnection, ck : CandidateKey ) : ( Promise ) { return QueryUtil.assertExistsByCk(connection, this, ck); } assertExistsByPk ( this : Extract, connection : IConnection, pk : PrimaryKey> ) : ( Promise ) { return QueryUtil.assertExistsByPk(connection, this, pk); } assertExistsBySk ( connection : IConnection, sk : SuperKey ) : ( Promise ) { return QueryUtil.assertExistsBySk(connection, this, sk); } existsByCk ( connection : IConnection, ck : CandidateKey ) : ( Promise ) { return QueryUtil.existsByCk(connection, this, ck); } existsByPk ( this : Extract, connection : IConnection, pk : PrimaryKey> ) : ( Promise ) { return QueryUtil.existsByPk(connection, this, pk); } existsBySk ( connection : IConnection, sk : SuperKey ) : ( Promise ) { return QueryUtil.existsBySk(connection, this, sk); } fetchOneByCk ( connection : IConnection, ck : CandidateKey ) : Promise>; fetchOneByCk< DelegateT extends QueryUtil.SelectDelegate< QueryUtil.From > > ( connection : IConnection, ck : CandidateKey, delegate : QueryUtil.AssertValidSelectDelegate< QueryUtil.From, DelegateT > ) : Promise>>; fetchOneByCk ( connection : IConnection, ck : CandidateKey, delegate? : (...args : any[]) => any[] ) { if (delegate == undefined) { return QueryUtil.fetchOneByCk(connection, this, ck); } else { return QueryUtil.fetchOneByCk(connection, this, ck, delegate as any); } } fetchOneByPk ( this : Extract, connection : IConnection, pk : PrimaryKey> ) : ( Promise> ); fetchOneByPk< DelegateT extends QueryUtil.SelectDelegate< QueryUtil.From> > > ( this : Extract, connection : IConnection, pk : PrimaryKey>, delegate : QueryUtil.AssertValidSelectDelegate< QueryUtil.From>, DelegateT > ) : Promise>>; fetchOneByPk ( this : Extract, connection : IConnection, pk : PrimaryKey>, delegate? : (...args : any[]) => any ) { if (delegate == undefined) { return QueryUtil.fetchOneByPk(connection, this, pk); } else { return QueryUtil.fetchOneByPk(connection, this, pk, delegate as any); } } fetchOneBySk ( connection : IConnection, sk : SuperKey ) : Promise>; fetchOneBySk< DelegateT extends QueryUtil.SelectDelegate< QueryUtil.From > > ( connection : IConnection, sk : SuperKey, delegate : QueryUtil.AssertValidSelectDelegate< QueryUtil.From, DelegateT > ) : Promise>>; fetchOneBySk ( connection : IConnection, sk : SuperKey, delegate? : (...args : any[]) => any[] ) { if (delegate == undefined) { return QueryUtil.fetchOneBySk(connection, this, sk); } else { return QueryUtil.fetchOneBySk(connection, this, sk, delegate as any); } } fetchValueByCk< DelegateT extends QueryUtil.SelectValueDelegate > ( connection : IConnection, ck : CandidateKey, delegate : QueryUtil.AssertValidSelectValueDelegate ) : ( Promise< RawExprUtil.TypeOf> > ) { return QueryUtil.fetchValueByCk( connection, this, ck, delegate ); } fetchValueByPk< DelegateT extends QueryUtil.SelectValueDelegate> > ( this : Extract, connection : IConnection, pk : PrimaryKey>, delegate : QueryUtil.AssertValidSelectValueDelegate, DelegateT> ) : ( Promise< RawExprUtil.TypeOf> > ) { return QueryUtil.fetchValueByPk, DelegateT>( connection, this, pk, delegate ); } fetchValueBySk< DelegateT extends QueryUtil.SelectValueDelegate > ( connection : IConnection, sk : SuperKey, delegate : QueryUtil.AssertValidSelectValueDelegate ) : ( Promise< RawExprUtil.TypeOf> > ) { return QueryUtil.fetchValueBySk( connection, this, sk, delegate ); } fetchValueOrUndefinedByCk< DelegateT extends QueryUtil.SelectValueDelegate > ( connection : IConnection, ck : CandidateKey, delegate : QueryUtil.AssertValidSelectValueDelegate ) : ( Promise< RawExprUtil.TypeOf>|undefined > ) { return QueryUtil.fetchValueOrUndefinedByCk( connection, this, ck, delegate ); } fetchValueOrUndefinedByPk< DelegateT extends QueryUtil.SelectValueDelegate> > ( this : Extract, connection : IConnection, pk : PrimaryKey>, delegate : QueryUtil.AssertValidSelectValueDelegate, DelegateT> ) : ( Promise< RawExprUtil.TypeOf>|undefined > ) { return QueryUtil.fetchValueOrUndefinedByPk, DelegateT>( connection, this, pk, delegate ); } fetchValueOrUndefinedBySk< DelegateT extends QueryUtil.SelectValueDelegate > ( connection : IConnection, sk : SuperKey, delegate : QueryUtil.AssertValidSelectValueDelegate ) : ( Promise< RawExprUtil.TypeOf>|undefined > ) { return QueryUtil.fetchValueOrUndefinedBySk( connection, this, sk, delegate ); } fetchZeroOrOneByCk ( connection : IConnection, ck : CandidateKey ) : Promise|undefined>; fetchZeroOrOneByCk< DelegateT extends QueryUtil.SelectDelegate< QueryUtil.From > > ( connection : IConnection, ck : CandidateKey, delegate : QueryUtil.AssertValidSelectDelegate< QueryUtil.From, DelegateT > ) : Promise>|undefined>; fetchZeroOrOneByCk ( connection : IConnection, ck : CandidateKey, delegate? : (...args : any[]) => any[] ) { if (delegate == undefined) { return QueryUtil.fetchZeroOrOneByCk(connection, this, ck); } else { return QueryUtil.fetchZeroOrOneByCk(connection, this, ck, delegate as any); } } fetchZeroOrOneByPk ( this : Extract, connection : IConnection, pk : PrimaryKey> ) : ( Promise|undefined> ); fetchZeroOrOneByPk< DelegateT extends QueryUtil.SelectDelegate< QueryUtil.From> > > ( this : Extract, connection : IConnection, pk : PrimaryKey>, delegate : QueryUtil.AssertValidSelectDelegate< QueryUtil.From>, DelegateT > ) : Promise>|undefined>; fetchZeroOrOneByPk ( this : Extract, connection : IConnection, pk : PrimaryKey>, delegate? : (...args : any[]) => any ) { if (delegate == undefined) { return QueryUtil.fetchZeroOrOneByPk(connection, this, pk); } else { return QueryUtil.fetchZeroOrOneByPk(connection, this, pk, delegate as any); } } fetchZeroOrOneBySk ( connection : IConnection, sk : SuperKey ) : Promise|undefined>; fetchZeroOrOneBySk< DelegateT extends QueryUtil.SelectDelegate< QueryUtil.From > > ( connection : IConnection, sk : SuperKey, delegate : QueryUtil.AssertValidSelectDelegate< QueryUtil.From, DelegateT > ) : Promise>|undefined>; fetchZeroOrOneBySk ( connection : IConnection, sk : SuperKey, delegate? : (...args : any[]) => any[] ) { if (delegate == undefined) { return QueryUtil.fetchZeroOrOneBySk(connection, this, sk); } else { return QueryUtil.fetchZeroOrOneBySk(connection, this, sk, delegate as any); } } insertAndFetch< RowT extends InsertRow> > ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, insertRow : RowT ) : Promise, RowT>> { return InsertUtil.insertAndFetch, RowT>( connection, this, insertRow ); } insertIgnore ( this : Extract, connection : IConnection, insertRow : InsertRow> ) : ( Promise>> ) { return InsertUtil.insertIgnore(connection, this, insertRow); } insert ( this : Extract, connection : IConnection, insertRow : InsertRow> ) : ( Promise>> ) { return InsertUtil.insert(connection, this, insertRow); } replace ( this : Extract, connection : IConnection, insertRow : InsertRow> ) : ( Promise>> ) { return InsertUtil.replace(connection, this, insertRow); } updateAndFetchOneByCk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, ck : CandidateKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise> > ) { return UpdateUtil.updateAndFetchOneByCk( connection, this, ck, delegate ); } updateAndFetchOneByPk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable> > ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, pk : PrimaryKey>, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< Extract, DelegateT, Promise, DelegateT >> > ) { return UpdateUtil.updateAndFetchOneByPk, DelegateT>( connection, this, pk, delegate ); } updateAndFetchOneBySk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, sk : SuperKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise> > ) { return UpdateUtil.updateAndFetchOneBySk( connection, this, sk, delegate ); } updateAndFetchZeroOrOneByCk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, ck : CandidateKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise> > ) { return UpdateUtil.updateAndFetchZeroOrOneByCk( connection, this, ck, delegate ); } updateAndFetchZeroOrOneByPk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable> > ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, pk : PrimaryKey>, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< Extract, DelegateT, Promise, DelegateT >> > ) { return UpdateUtil.updateAndFetchZeroOrOneByPk, DelegateT>( connection, this, pk, delegate ); } updateAndFetchZeroOrOneBySk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, sk : SuperKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise> > ) { return UpdateUtil.updateAndFetchZeroOrOneBySk( connection, this, sk, delegate ); } updateOneByCk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, ck : CandidateKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise > ) { return UpdateUtil.updateOneByCk( connection, this, ck, delegate ); } updateOneByPk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable> > ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, pk : PrimaryKey>, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< Extract, DelegateT, Promise > ) { return UpdateUtil.updateOneByPk, DelegateT>( connection, this, pk, delegate ); } updateOneBySk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, sk : SuperKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise > ) { return UpdateUtil.updateOneBySk( connection, this, sk, delegate ); } updateZeroOrOneByCk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, ck : CandidateKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise > ) { return UpdateUtil.updateZeroOrOneByCk( connection, this, ck, delegate ); } updateZeroOrOneByPk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable> > ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, pk : PrimaryKey>, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< Extract, DelegateT, Promise > ) { return UpdateUtil.updateZeroOrOneByPk, DelegateT>( connection, this, pk, delegate ); } updateZeroOrOneBySk< DelegateT extends UpdateUtil.SingleTableSetDelegateFromTable > ( this : this & TableUtil.AssertHasCandidateKey, connection : IConnection, sk : SuperKey, delegate : DelegateT ) : ( UpdateUtil.AssertValidSingleTableSetDelegateFromTable_Hack< this, DelegateT, Promise > ) { return UpdateUtil.updateZeroOrOneBySk( connection, this, sk, delegate ); } deleteOneByCk ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, ck : CandidateKey> ) : ( Promise ) { return DeleteUtil.deleteOneByCk(connection, this, ck); } deleteOneByPk ( this : Extract, connection : IConnection, pk : PrimaryKey> ) : ( Promise ) { return DeleteUtil.deleteOneByPk(connection, this, pk); } deleteOneBySk ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, sk : SuperKey> ) : ( Promise ) { return DeleteUtil.deleteOneBySk(connection, this, sk); } deleteZeroOrOneByCk ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, ck : CandidateKey> ) : ( Promise ) { return DeleteUtil.deleteZeroOrOneByCk(connection, this, ck); } deleteZeroOrOneByPk ( this : Extract, connection : IConnection, pk : PrimaryKey> ) : ( Promise ) { return DeleteUtil.deleteZeroOrOneByPk(connection, this, pk); } deleteZeroOrOneBySk ( this : Extract & TableUtil.AssertHasCandidateKey, connection : IConnection, sk : SuperKey> ) : ( Promise ) { return DeleteUtil.deleteZeroOrOneBySk(connection, this, sk); } }