import * as sd from "type-mapping"; import {TableWithPk} from "../table"; import {ColumnMapUtil} from "../column-map"; import {TypeMapUtil} from "../type-map"; export type PrimaryKey = ( TableT extends TableWithPk ? TypeMapUtil.FromColumnMap< Pick< TableT["columns"], TableT["primaryKey"][number] > > : never ); export namespace PrimaryKeyUtil { export type AssertDelegate = ( sd.SafeMapper> ); export function assertDelegate ( table : TableT ) : ( AssertDelegate ) { return ColumnMapUtil.assertDelegate( ColumnMapUtil.pick(table.columns, table.primaryKey) ) as any; } }