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