forked from mirror/gorm
Update README
This commit is contained in:
parent
9776eea2a2
commit
9a63fb28ba
|
@ -661,12 +661,11 @@ Association Mode contains some helper methods to handle relationship things easi
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Start Association Mode
|
// Start Association Mode
|
||||||
db.Model(&source).Association(fieldNameOfRelationship)
|
var user User
|
||||||
|
|
||||||
db.Model(&user).Association("Languages")
|
db.Model(&user).Association("Languages")
|
||||||
// source (user) need to have a valid primary key
|
// `user` is the source, it need to be a valid record (contains primary key)
|
||||||
// fieldNameOfRelationship ("Languages") need to be a valid relationship of source
|
// `Languages` is source's field name for a relationship.
|
||||||
// If not, it will return error, check it with:
|
// If those conditions not matched, will return an error, check it with:
|
||||||
// db.Model(&user).Association("Languages").Error
|
// db.Model(&user).Association("Languages").Error
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue