✨ Sticker will preload attachment
This commit is contained in:
parent
dfde530ca4
commit
75ab320bf1
@ -36,7 +36,7 @@ func listStickers(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var stickers []models.Sticker
|
||||
if err := tx.Limit(take).Offset(offset).Find(&stickers).Error; err != nil {
|
||||
if err := tx.Limit(take).Offset(offset).Preload("Attachment").Find(&stickers).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
return c.JSON(stickers)
|
||||
|
@ -15,7 +15,7 @@ func GetStickerPackWithUser(id, userId uint) (models.StickerPack, error) {
|
||||
|
||||
func ListStickerPackWithStickers(take, offset int) ([]models.StickerPack, error) {
|
||||
var packs []models.StickerPack
|
||||
if err := database.C.Limit(take).Offset(offset).Preload("Stickers").Find(&packs).Error; err != nil {
|
||||
if err := database.C.Limit(take).Offset(offset).Preload("Stickers").Preload("Stickers.Attachment").Find(&packs).Error; err != nil {
|
||||
return packs, err
|
||||
}
|
||||
return packs, nil
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
func GetSticker(id uint) (models.Sticker, error) {
|
||||
var sticker models.Sticker
|
||||
if err := database.C.Where("id = ?", id).First(&sticker).Error; err != nil {
|
||||
if err := database.C.Where("id = ?", id).Preload("Attachment").First(&sticker).Error; err != nil {
|
||||
return sticker, err
|
||||
}
|
||||
return sticker, nil
|
||||
|
Loading…
Reference in New Issue
Block a user