From e475d7c52b42e823ae8af9335ec02b028b74f104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20S=C3=A1nchez=20Marino?= Date: Sun, 2 Aug 2015 10:19:24 +0200 Subject: [PATCH] documented foreignkey --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index dbfbedd5..4f21a6ee 100644 --- a/README.md +++ b/README.md @@ -1111,6 +1111,16 @@ type Animal struct { } ``` +Associations on non-standard column names must be defined using `foreignkey` on the associated field: + +```go + AnimalId int64 `gorm:"column:beast_id;primary_key"` + Birthday time.Time `gorm:"column:day_of_the_beast"` + Age int64 `gorm:"column:age_of_the_beast"` + OwnerID int64 `gorm:"column:owner"` + Owner Owner `gorm:"foreignkey:OwnerID"` +``` + ## Composite Primary Key ```go