From 87502eab190ff6344ebd00cbbed4bba56b3c73c3 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Sun, 10 Jun 2018 16:12:55 +0200 Subject: [PATCH] #66 added union type with null for nullable columns --- src/Engine.ts | 2 +- src/entity.mst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Engine.ts b/src/Engine.ts index 799f321..047a250 100644 --- a/src/Engine.ts +++ b/src/Engine.ts @@ -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" ] diff --git a/src/entity.mst b/src/entity.mst index 86d5279..14236f0 100644 --- a/src/entity.mst +++ b/src/entity.mst @@ -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}}