Update README.md

This commit is contained in:
Sendy Halim 2015-02-07 18:08:25 +07:00
parent a8b3e8d3e2
commit d861d8737e
1 changed files with 7 additions and 0 deletions

View File

@ -146,6 +146,13 @@ db.AutoMigrate(&User{}, &Product{}, &Order{})
// Add index
db.Model(&User{}).AddIndex("idx_user_name", "name")
// Add foreign key
// 1st param : foreignkey field
// 2nd param : destination table(id)
// 3rd param : ONDELETE
// 4th param : ONUPDATE
db.Model(&User{}).AddForeignKey("user_id", "destination_table(id)", "CASCADE", "RESTRICT")
// Multiple column index
db.Model(&User{}).AddIndex("idx_user_name_age", "name", "age")