When I try to preload, like described in docs I get the error Cameras: unsupported relations for schema RecordingServer
I am unsing the schema also for json validation and dont want use Gorm Model and have Guid with type uuid as my primary keys. I am unable to come accross this issue by itself, so any help would be appreciated. Of course I read other posts but dont find a solution that fits.
var rs []sdk.RecordingServer
err := database.Session.Preload("Cameras").Find(&rs)
fmt.Println(err, rs)
// Cameras: unsupported relations for schema RecordingServer
# Models
type RecordingServerBase struct {
Name string `json:"name" gorm:"size:128"`
Address string `json:"address" gorm:"size:16"`
Cameras []Camera `json:"cameras" gorm:"foreignKey:RecordingServerGuid;type:uuid"`
}
type RecordingServer struct {
Guid uuid.UUID `json:"guid" format:"uuid" gorm:"type:uuid;primaryKey";`
RecordingServerBase
}
type CameraBase struct {
Name string `json:"name" gorm:"size:128"`
Address string `json:"address" gorm:"size:16"`
Username string `json:"username" gorm:"size:32"`
Password string `json:"password" gorm:"size:64"`
RecordingServerGuid uuid.UUID
}
type Camera struct {
Guid uuid.UUID `json:"guid" format:"uuid" gorm:"type:uuid;primaryKey";`
CameraBase
}
When I do just a plain sql it works with
SELECT * FROM `cameras` WHERE recording_server_guid IN ('55c0b198-9ec3-4270-8030-77546ab40c19');
Thanks