Update README

This commit is contained in:
Jinzhu 2014-09-12 16:40:55 +08:00
parent 0f3a9a8d02
commit 88858a942e

View File

@ -120,36 +120,36 @@ db.SingularTable(true)
```go ```go
// Create table // Create table
db.CreateTable(User{}) db.CreateTable(&User{})
// Drop table // Drop table
db.DropTable(User{}) db.DropTable(&User{})
// Drop table if exists // Drop table if exists
db.DropTableIfExists(User{}) db.DropTableIfExists(&User{})
// Automating Migration // Automating Migration
db.AutoMigrate(User{}) db.AutoMigrate(&User{})
db.AutoMigrate(User{}, Product{}, Order{}) db.AutoMigrate(&User{}, &Product{}, &Order{})
// Feel free to change your struct, AutoMigrate will keep your database up-to-date. // Feel free to change your struct, AutoMigrate will keep your database up-to-date.
// Fyi, AutoMigrate will only *add new columns*, it won't update column's type or delete unused columns, to make sure your data is safe. // Fyi, AutoMigrate will only *add new columns*, it won't update column's type or delete unused columns, to make sure your data is safe.
// If the table is not existing, AutoMigrate will create the table automatically. // If the table is not existing, AutoMigrate will create the table automatically.
// Add index // Add index
db.Model(User{}).AddIndex("idx_user_name", "name") db.Model(&User{}).AddIndex("idx_user_name", "name")
// Multiple column index // Multiple column index
db.Model(User{}).AddIndex("idx_user_name_age", "name", "age") db.Model(&User{}).AddIndex("idx_user_name_age", "name", "age")
// Add unique index // Add unique index
db.Model(User{}).AddUniqueIndex("idx_user_name", "name") db.Model(&User{}).AddUniqueIndex("idx_user_name", "name")
// Multiple column unique index // Multiple column unique index
db.Model(User{}).AddUniqueIndex("idx_user_name_age", "name", "age") db.Model(&User{}).AddUniqueIndex("idx_user_name_age", "name", "age")
// Remove index // Remove index
db.Model(User{}).RemoveIndex("idx_user_name") db.Model(&User{}).RemoveIndex("idx_user_name")
``` ```
# Basic CRUD # Basic CRUD