Skip to content

Commit

Permalink
Update polymorphism.md (#774)
Browse files Browse the repository at this point in the history
Fixed error
  • Loading branch information
theNailz authored Jul 12, 2024
1 parent 88fa525 commit 1b2c5cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pages/docs/polymorphism.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can specify polymorphism properties separately using the following GORM tags
type Dog struct {
ID int
Name string
Toys Toy `gorm:"polymorphicType:Kind;polymorphicId:OwnerID;polymorphicValue:master"`
Toys []Toy `gorm:"polymorphicType:Kind;polymorphicId:OwnerID;polymorphicValue:master"`
}

type Toy struct {
Expand All @@ -55,4 +55,4 @@ db.Create(&Dog{Name: "dog1", Toys: []Toy{{Name: "toy1"}, {Name: "toy2"}}})
// INSERT INTO `toys` (`name`,`owner_id`,`kind`) VALUES ("toy1",1,"master"), ("toy2",1,"master")
```

In these examples, we've used a has-many relationship, but the same principles apply to has-one relationships.
In these examples, we've used a has-many relationship, but the same principles apply to has-one relationships.

0 comments on commit 1b2c5cf

Please sign in to comment.