From 88858a942e87c27f9299c6421506af0094dc3c65 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 12 Sep 2014 16:40:55 +0800 Subject: [PATCH] Update README --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index db9e32d7..4f5236f7 100644 --- a/README.md +++ b/README.md @@ -120,36 +120,36 @@ db.SingularTable(true) ```go // Create table -db.CreateTable(User{}) +db.CreateTable(&User{}) // Drop table -db.DropTable(User{}) +db.DropTable(&User{}) // Drop table if exists -db.DropTableIfExists(User{}) +db.DropTableIfExists(&User{}) // Automating Migration -db.AutoMigrate(User{}) -db.AutoMigrate(User{}, Product{}, Order{}) +db.AutoMigrate(&User{}) +db.AutoMigrate(&User{}, &Product{}, &Order{}) // 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. // If the table is not existing, AutoMigrate will create the table automatically. // Add index -db.Model(User{}).AddIndex("idx_user_name", "name") +db.Model(&User{}).AddIndex("idx_user_name", "name") // 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 -db.Model(User{}).AddUniqueIndex("idx_user_name", "name") +db.Model(&User{}).AddUniqueIndex("idx_user_name", "name") // 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 -db.Model(User{}).RemoveIndex("idx_user_name") +db.Model(&User{}).RemoveIndex("idx_user_name") ``` # Basic CRUD