I am using GORM in combination with Fiber. When querying all users with preloaded clause.Associations
I get the following error:
can't preload field @@@as@@@ for entities.User
What does that mean? Without the preload
of clause.Associations
it works normally and but it does not show one-to-one associations.
func UsersGetAll(c *fiber.Ctx) error {
db := database.DBConn
users := []entities.User{}
records := db.Preload(clause.Associations).Find(&users)
if records.Error != nil {
log.Println(records.Error)
return c.Status(500).SendString(records.Error.Error())
}
return c.JSON(records.Value)
}