Найти значение в отношении много 2 много
У меня есть 2 структуры со многими отношениями 2:
type Post struct {
*gorm.Model
ID uint `gorm: "primarykey"`
PostTitle string `json: "posttitle" gorm:"posttitle;not null"`
PostSlug string `json: "postslug" gorm:"postslug;unique;not null"`
PostShortDesc string `json: "postshortdesc" gorm:"postshortdesc;not null"`
PostContent string `gorm: "postcontent;not null"`
PostAuthor uint `gorm:"postauthor;not null"`
PostStatus uint8 `gorm:"poststatus;not null"`
PostPubnish uint8 `gorm:"postpubnish;not null"`
PostFeature bool `gorm:"postfeature;not null;default:false`
PostCategories []PostCategory `gorm:"many2many:post_category;"`
PostCollections []PostCollection `gorm:"many2many:post_collection;"`
PostTags []PostTag `gorm:"many2many:post_tag;"`
PostImg string `json: "postimg" gorm:"postimg"`
}
type PostCategory struct {
ID uint64 `gorm: "primarykey"`
PostCatName string `json: "postcatname" gorm:"postcatname;not null"`
PostCatSlug string `json: "postcatslug" gorm:"postcatslug;unique;not null"`
PostCatParent uint `json: "postcatparent" gorm: "postcatparent"`
}
Как я могу найти все сообщения в категории с PostCatName = "Category A", пожалуйста?