Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Kmore<D, Dict>

Generate knex method refer to tables. method name from keyof T, ReturnType is the type according to the key, props both enumerable and unenumerable.

description

T = { user: {id: number, name: string} } will get db.user() => Knex.QueryBuilder<{id: number, name: string}>

Type parameters

  • D: DbModel = DbModel

  • Dict: DbDictModel | void = void

Hierarchy

  • DbDict<D, Dict>
    • Kmore

Index

Properties

Readonly [KmorePropKeys.DbModelAlias]

[KmorePropKeys.DbModelAlias]: DbModelFromAlias<D, "aliasColumns" extends keyof Dict ? Dict["aliasColumns"] : void>

Readonly [KmorePropKeys.DbModel]

[KmorePropKeys.DbModel]: D

Type ref to generics param Db only, do NOT access as variable!

example
const km = kmore<Db, KDD>({ config })
type DbRef = typeof km.DbModel
type User = DbRef['tb_user']  // equal to Db['tb_user']

Readonly [KmorePropKeys.dbh]

[KmorePropKeys.dbh]: Knex

Readonly [KmorePropKeys.refTables]

[KmorePropKeys.refTables]: DbRefBuilder<D>

aliasColumns

aliasColumns: "aliasColumns" extends keyof Dict ? DbAliasCols<D, Dict["aliasColumns"]> : DbAliasCols<D>

For table joint

{
  tb_user: {
    tbUserUid: "tb_user.uid",
    tbUserName: "tb_user.name",
    ...
  },
  tb_user_detail: {
    tbUserDetailUid: "tb_user_detail.uid"
  },
  ...,
}

columns

columns: "columns" extends keyof Dict ? DbCols<D, Dict["columns"]> : DbCols<D>

Columns mapping object, tb_name w/o table prefix

{
   tb_name: { col_alias: "col_name", ..., }
}

scopedColumns

scopedColumns: "scopedColumns" extends keyof Dict ? DbCols<D, Dict["scopedColumns"]> : DbCols<D>

Columns mapping object, column name with table prefix, eg tb_foo.user

{
  tb_user: {
    uid: "tb_user.uid",
    name: "tb_user.name",
    ...
  },
  tb_user_detail: {...},
  ...,
}

tables

tables: "tables" extends keyof Dict ? Tables<D, Dict["tables"]> : Tables<D>

Tables alias/name pairs { tb_name: "tb_name" }

Generated using TypeDoc