mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
enhance GetResourceByID to preload specific fields for Tags
This commit is contained in:
@@ -36,7 +36,9 @@ func GetResourceByID(id uint) (model.Resource, error) {
|
||||
var r model.Resource
|
||||
if err := db.Preload("User").
|
||||
Preload("Images").
|
||||
Preload("Tags").
|
||||
Preload("Tags", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("id", "name", "type", "alias_of")
|
||||
}).
|
||||
Preload("Files").
|
||||
Preload("Files.User").
|
||||
First(&r, id).Error; err != nil {
|
||||
|
Reference in New Issue
Block a user