|
- import * as Sequelize from 'sequelize'
-
- type ModelAttribute = {
- allowNull?: boolean,
- primaryKey?: boolean,
- type: Sequelize.DataType,
- }
-
- type Model = {
- tableName?: string,
- modelName?: string,
- options?: {
- timestamps?: boolean,
- paranoid?: boolean,
- createdAt?: string | boolean,
- updatedAt?: string | boolean,
- deletedAt?: string | boolean,
- },
- rawAttributes: Record<string, ModelAttribute>,
- }
-
- type InferType<V extends Sequelize.DataType> = (
- V extends typeof Sequelize.STRING ? string :
- V extends typeof Sequelize.TEXT ? string :
- V extends ReturnType<typeof Sequelize.TEXT> ? string :
- V extends typeof Sequelize.DATE ? Date :
- V extends typeof Sequelize.DATEONLY ? Date :
- V extends typeof Sequelize.UUIDV4 ? string :
- unknown
- )
-
- type InferProps<M extends Model> = {
- [K in keyof M['rawAttributes']]-?: InferType<M['rawAttributes'][K]['type']>
- }
-
- export default InferProps
|