ts-sql-codegen / ExportOptions
-
input
<typeofExportOptionsSchema
>↳
ExportOptions
- columnTypeMappingInterface
- crudRepository
- extractedColumns
- rowTypes
- tableClasses
- tableInstances
- valuesTypes
• Optional
columnTypeMappingInterface: boolean
Additionally export a column types mapping useful for constructing filter type for dynamic conditions.
Example: export type UserCols = { id: 'int' name: 'string' }
z.input.columnTypeMappingInterface
• Optional
crudRepository: boolean
Generate a repository class to simplify common single-table CRUD operations
This is currently only supported for tables having an id column as primary key
z.input.crudRepository
• Optional
extractedColumns: boolean
Additionally export the extracted columns (Useful for select * queries etc.)
Example: export const tUserCols = extractColumnsFrom(tUser)
z.input.extractedColumns
• Optional
rowTypes: boolean
| { asInterface
: boolean
}
Additionally export the row types associated with table
Example: import { InsertableRow, UpdatableRow, SelectedRow } from "ts-sql-query/extras/types"
export class UserTable extends Table<DBConnection, "User"> { ... }
// Type of user row that can be used for insert
// Here computed columns will not be present and columns with defaults will be optional
export type UserIRow = InsertableRow<UserTable>
// Type of user row that can be used for update
// Here computed columns will not be present and all fields will be optional
export type UserURow = UpdatableRow<UserTable>
// Type of user row that is returned from select
// Here computed columns will be present, only nullable fields will be optional
export type UserSRow = SelectedRow<UserTable>
z.input.rowTypes
• Optional
tableClasses: boolean
If set to false, prevents the table class from getting exported
This is useful in conjunction with tableInstances, if you only want to export the table instance
z.input.tableClasses
• Optional
tableInstances: boolean
In addition to the table class, also expose instantiated instance of table class
Example: export class UserTable extends Table<DBConnection, "User"> { ... }
export const tUserTable = new UserTable() // <----
z.input.tableInstances
• Optional
valuesTypes: boolean
| { asInterface
: boolean
}
Additionally export the value types associated with table
Example: import { InsertableValues, UpdatableValues, SelectedValues } from "ts-sql-query/extras/types"
export class UserTable extends Table<DBConnection, "User"> { ... }
// Type of user values that can be used for insert
// Here computed columns will not be present and columns with defaults will be optional
export type InsertableUser = InsertableValues<UserTable>
// Type of user values that can be used for update
// Here computed columns will not be present and all fields will be optional
export type UpdatableUser = UpdatableValues<UserTable>
// Type of user values that is returned from select
// Here computed columns will be present, only nullable fields will be optional
export type User = SelectedValues<UserTable>
z.input.valuesTypes