diff --git a/README.md b/README.md index 8a5cfb0f..4ad61e2f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The fantastic ORM library for Golang, aims to be developer friendly. * Iteration Support via [Rows](#row--rows) * Scopes * sql.Scanner support +* Polymorphism * Every feature comes with tests * Convention Over Configuration * Developer Friendly @@ -507,6 +508,32 @@ db.Model(&user).Association("Languages").Clear() // Remove all relations between the user and languages ``` +### Polymorphism + +Supports polymorphic has-many and has-one associations. + +```go + type Cat struct { + Id int + Name string + Toy Toy `gorm:"polymorphic:Owner;"` + } + + type Dog struct { + Id int + Name string + Toy Toy `gorm:"polymorphic:Owner;"` + } + + type Toy struct { + Id int + Name string + OwnerId int + OwnerType int + } +``` +Note: polymorphic belongs-to and many-to-many are explicitly NOT supported, and will throw errors. + ## Advanced Usage ## FirstOrInit