Update README

This commit is contained in:
Jinzhu 2015-12-26 20:46:25 +08:00
parent 9776eea2a2
commit 9a63fb28ba
1 changed files with 4 additions and 5 deletions

View File

@ -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