Skip to content

Automatically generate models #2261

@Groxot

Description

@Groxot

Feature proposal

Automatically generate models like
https://github.com/sequelize/sequelize-auto
from existing database

something like for mssql:

Declare @TableName varchar(128)

Set @TableName = 'myTable'

  --@property({
  --  type: 'number',
  --  required: true,
  --})
  --Id: number;
  
  
select char(13)+'@property({ '+char(13)+
'	type: '''+
case DATA_TYPE 
when 'int'  then 'number' 
when 'varchar'  then 'string' 
when 'datetime' then 'date'
when 'bit' then 'boolean'
when 'smallint' then 'number'
when 'float' then 'number'
when 'text' then 'string'
else 'any' end
+''', '+char(13)+
'	required: ' +case IS_NULLABLE when 'YES' then 'false' else 'true' end +', '+char(13)+
'})'+char(13)+
''++COLUMN_NAME+case IS_NULLABLE when '' then 'false' else '?' end+':'+
case DATA_TYPE 
when 'int'  then 'number' 
when 'varchar'  then 'string' 
when 'datetime' then 'date'
when 'bit' then 'boolean'
when 'smallint' then 'number'
when 'float' then 'number'
when 'text' then 'string'
else 'any' end +';'

from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME=@TableName

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions