From 336bfb6f24ebb2677905f3b0c10a7ec637bee651 Mon Sep 17 00:00:00 2001 From: Mike Guida Date: Fri, 18 Oct 2019 08:37:18 +0000 Subject: [PATCH] docs: clarify comments on many-to-many sample (#4912) --- sample/sample4-many-to-many/entity/Post.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sample/sample4-many-to-many/entity/Post.ts b/sample/sample4-many-to-many/entity/Post.ts index 1a85f56092..eeda82588a 100644 --- a/sample/sample4-many-to-many/entity/Post.ts +++ b/sample/sample4-many-to-many/entity/Post.ts @@ -19,45 +19,47 @@ export class Post { @Column() text: string; - // post has relation with category, however inverse relation is not set (category does not have relation with post set) + // Post has relation with PostCategory, however inverse relation is not set + // (category does not have relation with post set) @ManyToMany(type => PostCategory, { cascade: true }) @JoinTable() categories: PostCategory[]; - // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this - // relation it will be inserted automatically to the db when you save this Post entity + // Post has relation with PostDetails. Cascade insert here means if there is a new PostDetails instance set + // on this relation, it will be inserted automatically to the db when you save this Post entity @ManyToMany(type => PostDetails, details => details.posts, { cascade: ["insert"] }) @JoinTable() details: PostDetails[]; - // post has relation with details. cascade update here means if new PostDetail instance will be set to this relation - // it will be inserted automatically to the db when you save this Post entity + // Post has relation with PostImage. Cascade update here means if there are changes to an existing PostImage, it + // will be updated automatically to the db when you save this Post entity @ManyToMany(type => PostImage, image => image.posts, { cascade: ["update"] }) @JoinTable() images: PostImage[]; - // post has relation with details. cascade update here means if new PostDetail instance will be set to this relation - // it will be inserted automatically to the db when you save this Post entity + // Post has relation with PostMetadata. No cascades here means that when saving a Post entity, there will be + // no creating/updating/destroying PostMetadata. @ManyToMany(type => PostMetadata, metadata => metadata.posts) @JoinTable() metadatas: PostMetadata[]; - // post has relation with details. full cascades here + // Post has relation with PostInformation. Full cascades here @ManyToMany(type => PostInformation, information => information.posts, { cascade: true }) @JoinTable() informations: PostInformation[]; - // post has relation with details. not cascades here. means cannot be persisted, updated or removed + // Post has relation with author. No cascades here means that when saving a Post entity, there will be + // no creating/updating/destroying PostAuthor. @ManyToMany(type => PostAuthor, author => author.posts) @JoinTable() authors: PostAuthor[]; -} \ No newline at end of file +}