#66 added union type with null for nullable columns

This commit is contained in:
Kononnable 2018-06-10 16:12:55 +02:00
parent 651a54ea79
commit 87502eab19
2 changed files with 3 additions and 3 deletions

View File

@ -223,7 +223,7 @@ export class Engine {
"username": "${this.Options.user}",
"password": "${this.Options.password}",
"database": "${this.Options.databaseName}",
"synchronize": false
"synchronize": false,
"entities": [
"entities/*.js"
]

View File

@ -22,12 +22,12 @@ import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, Man
enum:[{{.}}],{{/enumOptions}}
name:"{{name}}"
})
{{toPropertyName name}}:{{ts_type}};
{{toPropertyName name}}:{{ts_type}}{{#is_nullable}} | null{{/is_nullable}};
{{/relations}}{{#relations}}
@{{relationType}}(type=>{{toEntityName relatedTable}}, {{toPropertyName ../name}}=>{{toPropertyName ../name}}.{{#if isOwner}}{{toPropertyName ownerColumn}},{ {{#../isPrimary}}primary:true,{{/../isPrimary}}{{^../is_nullable}} nullable:false,{{/../is_nullable}}{{#actionOnDelete}}onDelete: '{{.}}',{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{else}}{{toPropertyName relatedColumn}}{{#actionOnDelete}},{ onDelete: '{{.}}' }{{/actionOnDelete}}{{/if}}){{#isOwner}}
{{#if isManyToMany}}@JoinTable(){{else}}@JoinColumn({ name:'{{ ../name}}'}){{/if}}{{/isOwner}}
{{#if (or isOneToMany isManyToMany)}}{{toPropertyName ../name}}:{{toLazy (concat (toEntityName relatedTable) "[]")}};
{{else}}{{toPropertyName ../name}}:{{toLazy (toEntityName relatedTable)}};
{{else}}{{toPropertyName ../name}}:{{toLazy (concat (toEntityName relatedTable) ' | null')}};
{{/if}}{{/relations}}
{{/Columns}}
{{#if GenerateConstructor}}