consistent ordering of structs in Belongs To docs
This commit is contained in:
parent
f1caf058c5
commit
46d24b77a4
@ -6,17 +6,17 @@
|
||||
|
||||
```go
|
||||
// `User` belongs to `Profile`, `ProfileID` is the foreign key
|
||||
type Profile struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Profile Profile
|
||||
ProfileID int
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
}
|
||||
|
||||
db.Model(&user).Related(&profile)
|
||||
//// SELECT * FROM profiles WHERE id = 111; // 111 is user's foreign key ProfileID
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user