You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the Golang Sheriff package with GORM Library somehow I'm getting an empty response. Tried a couple of ways no luck. Is it possible? Any help that would be great. TIA
//STRUCT
type Book struct {
ID uint `json:"id" gorm:"primary_key" groups:"not_detail,detail"`
Realname string `json:"real_name" groups:"not_detail,detail"`
LanguageId int `json:"language_id" groups:"not_detail,detail"`
Language Language `json:"Language" groups:"detail"`
CreatedAt time.Time `json:"created_at" groups:"not_detail,detail"`
UpdatedAt time.Time `json:"updated_at" groups:"not_detail,detail"`
}
//CONTROLLER LOGIC
func FindBooks(c *gin.Context) {
db := c.MustGet("db").(*gorm.DB)
var books []models.Book
result := db.Find(&books)
o := sheriff.Options{
Groups: []string{"not_detail"},
}
d, err := sheriff.Marshal(&o, result)
if err != nil {
panic(err)
}
c.JSON(http.StatusOK, gin.H{"data":d})
}
The text was updated successfully, but these errors were encountered:
I'm trying to use the Golang Sheriff package with GORM Library somehow I'm getting an empty response. Tried a couple of ways no luck. Is it possible? Any help that would be great. TIA
The text was updated successfully, but these errors were encountered: