mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
docs: clarify comments on many-to-many sample (#4912)
This commit is contained in:
parent
2bb0e398f9
commit
336bfb6f24
@ -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[];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user