✨ Preloading categories and tags
This commit is contained in:
@ -54,6 +54,8 @@ func GetArticleWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (m
|
||||
var item models.Article
|
||||
if err := tx.
|
||||
Where("alias = ?", alias).
|
||||
Preload("Tags").
|
||||
Preload("Categories").
|
||||
Preload("Realm").
|
||||
Preload("Author").
|
||||
First(&item).Error; err != nil {
|
||||
@ -71,6 +73,8 @@ func GetArticle(tx *gorm.DB, id uint, ignoreLimitation ...bool) (models.Article,
|
||||
var item models.Article
|
||||
if err := tx.
|
||||
Where("id = ?", id).
|
||||
Preload("Tags").
|
||||
Preload("Categories").
|
||||
Preload("Realm").
|
||||
Preload("Author").
|
||||
First(&item).Error; err != nil {
|
||||
|
@ -62,6 +62,8 @@ func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (mode
|
||||
var item models.Post
|
||||
if err := tx.
|
||||
Where("alias = ?", alias).
|
||||
Preload("Tags").
|
||||
Preload("Categories").
|
||||
Preload("Realm").
|
||||
Preload("Author").
|
||||
Preload("ReplyTo").
|
||||
@ -83,6 +85,8 @@ func GetPost(tx *gorm.DB, id uint, ignoreLimitation ...bool) (models.Post, error
|
||||
var item models.Post
|
||||
if err := tx.
|
||||
Where("id = ?", id).
|
||||
Preload("Tags").
|
||||
Preload("Categories").
|
||||
Preload("Realm").
|
||||
Preload("Author").
|
||||
Preload("ReplyTo").
|
||||
|
Reference in New Issue
Block a user