These are chat archives for jinzhu/gorm

16th
Jul 2017
kayamax
@kayamax
Jul 16 2017 16:12
is there any model generator from existing db schema for gorm, aka DatabaseFirst method?
Andrey Nering
@andreynering
Jul 16 2017 17:04
@kayamax AFAIK no, but I didn't search for it.
IM
@imboooooo
Jul 16 2017 17:16

hello,
type User struct {
gorm.Model
Id int
Profile Profile gorm:"ForeignKey:Id;AssociationForeignKey:ProfileID"
ProfileID int
}

type Profile struct {
gorm.Model
Id int
Name string
}

var use =User{Id:1}
var profile =use.Profile
db.Model(&user).Related(&profile)

i have this code, but something wrong to use Belong to in Gorm