added onUpdate to relation options
This commit is contained in:
parent
8fcbf66055
commit
426c6272fe
@ -24,7 +24,7 @@ import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, Man
|
||||
})
|
||||
{{toPropertyName name}}:{{ts_type}};
|
||||
{{/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}} }{{else}}{{toPropertyName relatedColumn}}{{#actionOnDelete}},{ onDelete: '{{.}}' }{{/actionOnDelete}}{{/if}}){{#isOwner}}
|
||||
@{{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)}};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn, ManyToOne, ManyToMany, JoinTable } from "typeorm"
|
||||
import {Author} from "./Author";
|
||||
import {Category} from "./Category";
|
||||
import { Author } from "./Author";
|
||||
import { Category } from "./Category";
|
||||
|
||||
@Entity("Post")
|
||||
export class Post {
|
||||
@ -16,9 +16,10 @@ export class Post {
|
||||
|
||||
@ManyToOne(type => Author, author => author.posts, {
|
||||
// cascade: ["insert"],
|
||||
onDelete: "SET NULL"
|
||||
onDelete: "SET NULL",
|
||||
onUpdate: "CASCADE"
|
||||
})
|
||||
author: Promise<Author|null>;
|
||||
author: Promise<Author | null>;
|
||||
|
||||
@ManyToMany(type => Category, category => category.Post, {
|
||||
// cascade: true
|
||||
|
Loading…
Reference in New Issue
Block a user